]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Add process= support for 'qemu-kvm -name'
authorJohn Morrissey <jwm@horde.net>
Wed, 20 Oct 2010 08:25:05 +0000 (10:25 +0200)
committerDaniel Veillard <veillard@redhat.com>
Wed, 20 Oct 2010 08:30:30 +0000 (10:30 +0200)
This sets the process name to the same value as the Windows title,
but since the name is limited to 16 chars only this is kept as a
configuration option and turned off by default
* src/qemu/qemu.conf src/qemu/qemu_conf.[ch]: hceck for support in the
  QEmu help output, add the option in qemu conf file and augment
  qemudBuildCommandLine to add it if switched on
* src/qemu/libvirtd_qemu.aug src/qemu/test_libvirtd_qemu.aug: augment
  the augeas lenses accordingly
* tests/qemuhelptest.c: cope with the extra flag being detected now

src/qemu/libvirtd_qemu.aug
src/qemu/qemu.conf
src/qemu/qemu_conf.c
src/qemu/qemu_conf.h
src/qemu/test_libvirtd_qemu.aug
tests/qemuhelptest.c

index 47d052575bac2ab9ff7aab1c875642c01af01c7e..b9ace3ed0c31f95e01fbe34f1a26550bb7ae2cca 100644 (file)
@@ -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
index bfb9f6ae85b3c0c8c9df82d5adf05455e4354001..53b76e718b80a6c5dab762b08e19bbc984d44233 100644 (file)
 #    "/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
 #
 # 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
 #
 # 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.
 #
 # 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.
 # 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.
 # 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
index ffe184b62fd680cd05fd6c5c83bba7fbb5795f11..5907bf3286281a8f899acff61f30316413526b32 100644 (file)
@@ -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"))
@@ -4034,7 +4041,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");
@@ -6477,9 +6493,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)))
index d2e6857bb6236c327b2b79a142d9d30b698be192..005031d63eab20d74d96156b29471c3008309e8c 100644 (file)
@@ -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;
 
index f0c4a0d4df2eaa7df8cd4a67ab19521abfeb4321..67883460e2f49f984442e0d197446fece3c6b9e5 100644 (file)
@@ -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" }
index d072cb0e5f34628404438e37ed1e00975b2761fd..d4453db1cde65ea9d70d8c5a088e4e2641e2a464 100644 (file)
@@ -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;