[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] process= support for 'qemu-kvm -name' [Bug 576950]



On Tue, Oct 19, 2010 at 05:45:42PM +0200, Daniel Veillard wrote:
>   Patch looks fine but I didn't applied it yet because "make check"
>   raises an error now:

D'oh, I nearly beat you to noticing. :-) I was just building some packages
with this patch, and noticed the test suite failure since the packages run
it as part of the build process.

Updated patch attached, sorry for the bother.

john
-- 
John Morrissey          _o            /\         ----  __o
jwm horde net        _-< \_          /  \       ----  <  \,
www.horde.net/    __(_)/_(_)________/    \_______(_) /_(_)__
diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug
index 47d0525..b9ace3e 100644
--- a/src/qemu/libvirtd_qemu.aug
+++ b/src/qemu/libvirtd_qemu.aug
@@ -32,7 +32,7 @@ module Libvirtd_qemu =
                  | str_entry "security_driver"
                  | str_entry "user"
                  | str_entry "group"
-		 | bool_entry "dynamic_ownership"
+                 | bool_entry "dynamic_ownership"
                  | str_array_entry "cgroup_controllers"
                  | str_array_entry "cgroup_device_acl"
                  | str_entry "save_image_format"
@@ -41,6 +41,7 @@ module Libvirtd_qemu =
                  | bool_entry "vnc_allow_host_audio"
                  | bool_entry "clear_emulator_capabilities"
                  | bool_entry "allow_disk_format_probing"
+                 | bool_entry "set_process_name"
 
    (* Each enty in the config is one of the following three ... *)
    let entry = vnc_entry
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index bfb9f6a..53b76e7 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -135,6 +135,7 @@
 #    "/dev/rtc", "/dev/hpet", "/dev/net/tun",
 #]
 
+
 # The default format for Qemu/KVM guest save images is raw; that is, the
 # memory from the domain is dumped out directly to a file.  If you have
 # guests with a large amount of memory, however, this can take up quite
@@ -146,6 +147,7 @@
 #
 # save_image_format = "raw"
 
+
 # If provided by the host and a hugetlbfs mount point is configured,
 # a guest may request huge page backing.  When this mount point is
 # unspecified here, determination of a host mount point in /proc/mounts
@@ -155,14 +157,16 @@
 #
 # NB, within this mount point, guests will create memory backing files
 # in a location of  $MOUNTPOINT/libvirt/qemu
-
+#
 # hugetlbfs_mount = "/dev/hugepages"
 
+
 # mac_filter enables MAC addressed based filtering on bridge ports.
 # This currently requires ebtables to be installed.
 #
 # mac_filter = 1
 
+
 # By default, PCI devices below non-ACS switch are not allowed to be assigned
 # to guests. By setting relaxed_acs_check to 1 such devices will be allowed to
 # be assigned to guests.
@@ -179,6 +183,7 @@
 #
 # vnc_allow_host_audio = 0
 
+
 # If clear_emulator_capabilities is enabled, libvirt will drop all
 # privileged capabilities of the QEmu/KVM emulator. This is enabled by
 # default.
@@ -189,7 +194,6 @@
 # clear_emulator_capabilities = 1
 
 
-
 # If allow_disk_format_probing is enabled, libvirt will probe disk
 # images to attempt to identify their format, when not otherwise
 # specified in the XML. This is disabled by default.
@@ -198,4 +202,15 @@
 # deployments. It is strongly recommended that users update their
 # guest XML <disk> elements to include  <driver type='XXXX'/>
 # elements instead of enabling this option.
+#
 # allow_disk_format_probing = 1
+
+
+# If enabled, libvirt will have QEMU set its process name to
+# "qemu:VM_NAME", where VM_NAME is the name of the VM. The QEMU
+# process will appear as "qemu:VM_NAME" in process listings and
+# other system monitoring tools. By default, QEMU does not set
+# its process title, so the complete QEMU command (emulator and
+# its arguments) appear in process listings.
+#
+# set_process_name = 1
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 83c0f83..81331a2 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -370,6 +370,10 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
     CHECK_TYPE ("allow_disk_format_probing", VIR_CONF_LONG);
     if (p) driver->allowDiskFormatProbing = p->l;
 
+    p = virConfGetValue (conf, "set_process_name");
+    CHECK_TYPE ("set_process_name", VIR_CONF_LONG);
+    if (p) driver->setProcessName = p->l;
+
     virConfFree (conf);
     return 0;
 }
@@ -1165,8 +1169,11 @@ static unsigned long long qemudComputeCmdFlags(const char *help,
         flags |= QEMUD_CMD_FLAG_ENABLE_KVM;
     if (strstr(help, "-no-reboot"))
         flags |= QEMUD_CMD_FLAG_NO_REBOOT;
-    if (strstr(help, "-name"))
+    if (strstr(help, "-name")) {
         flags |= QEMUD_CMD_FLAG_NAME;
+        if (strstr(help, ",process="))
+            flags |= QEMUD_CMD_FLAG_NAME_PROCESS;
+    }
     if (strstr(help, "-uuid"))
         flags |= QEMUD_CMD_FLAG_UUID;
     if (strstr(help, "-xen-domid"))
@@ -4025,7 +4032,16 @@ int qemudBuildCommandLine(virConnectPtr conn,
 
     if (qemuCmdFlags & QEMUD_CMD_FLAG_NAME) {
         ADD_ARG_LIT("-name");
-        ADD_ARG_LIT(def->name);
+        if (driver->setProcessName &&
+            (qemuCmdFlags & QEMUD_CMD_FLAG_NAME_PROCESS)) {
+            char *name;
+            if (virAsprintf(&name, "%s,process=\"qemu:%s\"",
+                            def->name, def->name) < 0)
+                goto no_memory;
+            ADD_ARG_LIT(name);
+        } else {
+            ADD_ARG_LIT(def->name);
+        }
     }
     if (qemuCmdFlags & QEMUD_CMD_FLAG_UUID) {
         ADD_ARG_LIT("-uuid");
@@ -6462,9 +6478,16 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps,
             if (strstr(val, "menu=on"))
                 def->os.bootmenu = 1;
         } else if (STREQ(arg, "-name")) {
+            char *process;
             WANT_VALUE();
-            if (!(def->name = strdup(val)))
-                goto no_memory;
+            process = strstr(val, ",process=");
+            if (process == NULL) {
+                if (!(def->name = strdup(val)))
+                    goto no_memory;
+            } else {
+                if (!(def->name = strndup(val, process - val)))
+                    goto no_memory;
+            }
         } else if (STREQ(arg, "-M")) {
             WANT_VALUE();
             if (!(def->os.machine = strdup(val)))
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index d2e6857..005031d 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -95,6 +95,7 @@ enum qemud_cmd_flags {
     QEMUD_CMD_FLAG_ENABLE_KQEMU  = (1LL << 39), /* -enable-kqemu flag */
     QEMUD_CMD_FLAG_FSDEV         = (1LL << 40), /* -fstype filesystem passthrough */
     QEMUD_CMD_FLAG_NESTING       = (1LL << 41), /* -enable-nesting (SVM/VMX) */
+    QEMUD_CMD_FLAG_NAME_PROCESS  = (1LL << 42), /* Is -name process= available */
 };
 
 /* Main driver state */
@@ -146,6 +147,7 @@ struct qemud_driver {
     unsigned int vncAllowHostAudio : 1;
     unsigned int clearEmulatorCapabilities : 1;
     unsigned int allowDiskFormatProbing : 1;
+    unsigned int setProcessName : 1;
 
     virCapsPtr caps;
 
diff --git a/src/qemu/test_libvirtd_qemu.aug b/src/qemu/test_libvirtd_qemu.aug
index f0c4a0d..6788346 100644
--- a/src/qemu/test_libvirtd_qemu.aug
+++ b/src/qemu/test_libvirtd_qemu.aug
@@ -96,6 +96,8 @@ save_image_format = \"gzip\"
 
 hugetlbfs_mount = \"/dev/hugepages\"
 
+set_process_name = 1
+
 relaxed_acs_check = 1
 
 vnc_allow_host_audio = 1
@@ -209,6 +211,8 @@ allow_disk_format_probing = 1
 { "#empty" }
 { "hugetlbfs_mount" = "/dev/hugepages" }
 { "#empty" }
+{ "set_process_name" = "1" }
+{ "#empty" }
 { "relaxed_acs_check" = "1" }
 { "#empty" }
 { "vnc_allow_host_audio" = "1" }
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index d072cb0..d4453db 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -224,7 +224,8 @@ mymain(int argc, char **argv)
             QEMUD_CMD_FLAG_NO_KVM_PIT |
             QEMUD_CMD_FLAG_TDF |
             QEMUD_CMD_FLAG_BOOT_MENU |
-            QEMUD_CMD_FLAG_NESTING,
+            QEMUD_CMD_FLAG_NESTING |
+            QEMUD_CMD_FLAG_NAME_PROCESS,
             10092, 1,  0);
     DO_TEST("qemu-0.12.1",
             QEMUD_CMD_FLAG_VNC_COLON |
@@ -249,7 +250,8 @@ mymain(int argc, char **argv)
             QEMUD_CMD_FLAG_SMP_TOPOLOGY |
             QEMUD_CMD_FLAG_RTC |
             QEMUD_CMD_FLAG_NO_HPET |
-            QEMUD_CMD_FLAG_BOOT_MENU,
+            QEMUD_CMD_FLAG_BOOT_MENU |
+            QEMUD_CMD_FLAG_NAME_PROCESS,
             12001, 0,  0);
     DO_TEST("qemu-kvm-0.12.3",
             QEMUD_CMD_FLAG_VNC_COLON |
@@ -281,7 +283,8 @@ mymain(int argc, char **argv)
             QEMUD_CMD_FLAG_NO_KVM_PIT |
             QEMUD_CMD_FLAG_TDF |
             QEMUD_CMD_FLAG_BOOT_MENU |
-            QEMUD_CMD_FLAG_NESTING,
+            QEMUD_CMD_FLAG_NESTING |
+            QEMUD_CMD_FLAG_NAME_PROCESS,
             12003, 1,  0);
 
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]