Add process= support for 'qemu-kvm -name'

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
This commit is contained in:
John Morrissey 2010-10-20 10:25:05 +02:00 committed by Daniel Veillard
parent c2fbdf1088
commit c08c7b0143
6 changed files with 58 additions and 10 deletions

View 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

View File

@ -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

View 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)))

View 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;

View 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" }

View 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;