[libvirt] [PATCH v3 0/3] qemu: Fix hotplug of guest agent

v3: - Change qemuhotplugtest so that it runs tests of live hotplug in every case, not only in the new one. - https://www.redhat.com/archives/libvir-list/2016-June/msg00109.html v2: - mostly a rebase, it was almost ACKed but not completely, just to make sure let's see it again with everything done. - use /tmp for paths in tests (automatically fixed by rebasing on top of commit 1893b6df117b) - https://www.redhat.com/archives/libvir-list/2016-April/msg01911.html v1: - https://www.redhat.com/archives/libvir-list/2016-March/msg01454.html Martin Kletzander (3): qemu: Move channel path generation out of command creation qemuhotplugtest: Test live data qemu: Generate channel target paths on hotplug as well src/qemu/qemu_command.c | 25 ++---------- src/qemu/qemu_command.h | 5 +-- src/qemu/qemu_domain.c | 20 ++++++++++ src/qemu/qemu_domain.h | 4 ++ src/qemu/qemu_hotplug.c | 3 ++ src/qemu/qemu_process.c | 12 ++++-- tests/qemuhotplugtest.c | 45 +++++++++++++--------- ...tplug-console-compat-2-live+console-virtio.xml} | 36 ++++++++++++++--- ...qemuhotplug-hotplug-base+qemu-agent-detach.xml} | 36 ++++++++++------- ...xml => qemuhotplug-hotplug-base+qemu-agent.xml} | 36 ++++++++++------- ...=> qemuhotplug-hotplug-base-live+disk-scsi.xml} | 24 +++++++++--- ... => qemuhotplug-hotplug-base-live+disk-usb.xml} | 24 +++++++++--- ... qemuhotplug-hotplug-base-live+disk-virtio.xml} | 24 +++++++++--- ...otplug-hotplug-base-live+qemu-agent-detach.xml} | 36 ++++++++++------- ...> qemuhotplug-hotplug-base-live+qemu-agent.xml} | 36 ++++++++++------- .../qemuhotplug-qemu-agent-detach.xml | 5 +++ .../qemuhotplugtestdata/qemuhotplug-qemu-agent.xml | 5 +++ .../qemuxml2argv-console-compat-2-live.xml} | 37 ++++++++++++++---- .../qemuxml2argv-hotplug-base-live.xml} | 30 ++++++++------- 19 files changed, 303 insertions(+), 140 deletions(-) copy tests/qemuhotplugtestdata/{qemuhotplug-console-compat-2+console-virtio.xml => qemuhotplug-console-compat-2-live+console-virtio.xml} (79%) copy tests/qemuhotplugtestdata/{qemuhotplug-hotplug-base+disk-scsi.xml => qemuhotplug-hotplug-base+qemu-agent-detach.xml} (59%) copy tests/qemuhotplugtestdata/{qemuhotplug-hotplug-base+disk-scsi.xml => qemuhotplug-hotplug-base+qemu-agent.xml} (60%) copy tests/qemuhotplugtestdata/{qemuhotplug-hotplug-base+disk-scsi.xml => qemuhotplug-hotplug-base-live+disk-scsi.xml} (73%) rename tests/qemuhotplugtestdata/{qemuhotplug-hotplug-base+disk-usb.xml => qemuhotplug-hotplug-base-live+disk-usb.xml} (72%) rename tests/qemuhotplugtestdata/{qemuhotplug-hotplug-base+disk-virtio.xml => qemuhotplug-hotplug-base-live+disk-virtio.xml} (73%) copy tests/qemuhotplugtestdata/{qemuhotplug-hotplug-base+disk-scsi.xml => qemuhotplug-hotplug-base-live+qemu-agent-detach.xml} (59%) copy tests/qemuhotplugtestdata/{qemuhotplug-hotplug-base+disk-scsi.xml => qemuhotplug-hotplug-base-live+qemu-agent.xml} (60%) create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-qemu-agent-detach.xml create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-qemu-agent.xml rename tests/{qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml => qemuxml2argvdata/qemuxml2argv-console-compat-2-live.xml} (80%) rename tests/{qemuhotplugtestdata/qemuhotplug-hotplug-base+disk-scsi.xml => qemuxml2argvdata/qemuxml2argv-hotplug-base-live.xml} (71%) -- 2.8.3

Put it into separate function called qemuDomainPrepareChannel() and call it from the new qemuProcessPrepareDomain(). Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/qemu/qemu_command.c | 25 +++---------------------- src/qemu/qemu_command.h | 5 ++--- src/qemu/qemu_domain.c | 20 ++++++++++++++++++++ src/qemu/qemu_domain.h | 4 ++++ src/qemu/qemu_process.c | 12 ++++++++---- 5 files changed, 37 insertions(+), 29 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 368bd871f7e3..72f42ae405b7 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8477,8 +8477,7 @@ static int qemuBuildChannelsCommandLine(virLogManagerPtr logManager, virCommandPtr cmd, const virDomainDef *def, - virQEMUCapsPtr qemuCaps, - const char *domainChannelTargetDir) + virQEMUCapsPtr qemuCaps) { size_t i; @@ -8510,22 +8509,6 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager, break; case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO: - /* - * TODO: Refactor so that we generate this (and onther - * things) somewhere else then where we are building the - * command line. - */ - if (channel->source.type == VIR_DOMAIN_CHR_TYPE_UNIX && - !channel->source.data.nix.path) { - if (virAsprintf(&channel->source.data.nix.path, - "%s/%s", domainChannelTargetDir, - channel->target.name ? channel->target.name - : "unknown.sock") < 0) - return -1; - - channel->source.data.nix.listen = true; - } - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPICEVMC) && channel->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) { /* spicevmc was originally introduced via a -device @@ -9189,8 +9172,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, virBitmapPtr nodeset, size_t *nnicindexes, int **nicindexes, - const char *domainLibDir, - const char *domainChannelTargetDir) + const char *domainLibDir) { size_t i; char uuid[VIR_UUID_STRING_BUFLEN]; @@ -9335,8 +9317,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildParallelsCommandLine(logManager, cmd, def, qemuCaps) < 0) goto error; - if (qemuBuildChannelsCommandLine(logManager, cmd, def, qemuCaps, - domainChannelTargetDir) < 0) + if (qemuBuildChannelsCommandLine(logManager, cmd, def, qemuCaps) < 0) goto error; if (qemuBuildConsoleCommandLine(logManager, cmd, def, qemuCaps) < 0) diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 1c2270564c16..22d835117ca1 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -62,9 +62,8 @@ virCommandPtr qemuBuildCommandLine(virQEMUDriverPtr driver, virBitmapPtr nodeset, size_t *nnicindexes, int **nicindexes, - const char *domainLibDir, - const char *domainChannelTargetDir) - ATTRIBUTE_NONNULL(15) ATTRIBUTE_NONNULL(16); + const char *domainLibDir) + ATTRIBUTE_NONNULL(15); /* Generate '-device' string for chardev device */ int diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c21465d41c76..93220183b2c0 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5471,3 +5471,23 @@ qemuDomainDefValidateDiskLunSource(const virStorageSource *src) return 0; } + + +int +qemuDomainPrepareChannel(virDomainChrDefPtr channel, + const char *domainChannelTargetDir) +{ + if (channel->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO && + channel->source.type == VIR_DOMAIN_CHR_TYPE_UNIX && + !channel->source.data.nix.path) { + if (virAsprintf(&channel->source.data.nix.path, + "%s/%s", domainChannelTargetDir, + channel->target.name ? channel->target.name + : "unknown.sock") < 0) + return -1; + + channel->source.data.nix.listen = true; + } + + return 0; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index a9a7295557ca..f037367ef2a8 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -681,4 +681,8 @@ int qemuDomainSecretPrepare(virConnectPtr conn, virDomainObjPtr vm) int qemuDomainDefValidateDiskLunSource(const virStorageSource *src) ATTRIBUTE_NONNULL(1); +int qemuDomainPrepareChannel(virDomainChrDefPtr chr, + const char *domainChannelTargetDir) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + #endif /* __QEMU_DOMAIN_H__ */ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index e847cd1f13d1..66d370d98d18 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4884,6 +4884,12 @@ qemuProcessPrepareDomain(virConnectPtr conn, if (qemuDomainSecretPrepare(conn, vm) < 0) goto cleanup; + for (i = 0; i < vm->def->nchannels; i++) { + if (qemuDomainPrepareChannel(vm->def->channels[i], + priv->channelTargetDir) < 0) + goto cleanup; + } + if (VIR_ALLOC(priv->monConfig) < 0) goto cleanup; @@ -5098,8 +5104,7 @@ qemuProcessLaunch(virConnectPtr conn, qemuCheckFips(), priv->autoNodeset, &nnicindexes, &nicindexes, - priv->libDir, - priv->channelTargetDir))) + priv->libDir))) goto cleanup; if (incoming && incoming->fd != -1) @@ -5516,8 +5521,7 @@ qemuProcessCreatePretendCmd(virConnectPtr conn, priv->autoNodeset, NULL, NULL, - priv->libDir, - priv->channelTargetDir); + priv->libDir); cleanup: return cmd; -- 2.8.3

On Sun, Jun 05, 2016 at 02:41:04 +0200, Martin Kletzander wrote:
Put it into separate function called qemuDomainPrepareChannel() and call it from the new qemuProcessPrepareDomain().
Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/qemu/qemu_command.c | 25 +++---------------------- src/qemu/qemu_command.h | 5 ++--- src/qemu/qemu_domain.c | 20 ++++++++++++++++++++ src/qemu/qemu_domain.h | 4 ++++ src/qemu/qemu_process.c | 12 ++++++++---- 5 files changed, 37 insertions(+), 29 deletions(-)
ACK

Until now, the only hot thing in this test was the name. That's because we set the id to '-1' before every test. With this change, we test the hotplug on live domains as the name suggests and as it should be. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- tests/qemuhotplugtest.c | 38 ++++++++++++---------- ...tplug-console-compat-2-live+console-virtio.xml} | 36 +++++++++++++++++--- ...=> qemuhotplug-hotplug-base-live+disk-scsi.xml} | 24 +++++++++++--- ... => qemuhotplug-hotplug-base-live+disk-usb.xml} | 24 +++++++++++--- ... qemuhotplug-hotplug-base-live+disk-virtio.xml} | 24 +++++++++++--- .../qemuxml2argv-console-compat-2-live.xml} | 37 ++++++++++++++++----- .../qemuxml2argv-hotplug-base-live.xml} | 30 +++++++++-------- 7 files changed, 154 insertions(+), 59 deletions(-) copy tests/qemuhotplugtestdata/{qemuhotplug-console-compat-2+console-virtio.xml => qemuhotplug-console-compat-2-live+console-virtio.xml} (79%) rename tests/qemuhotplugtestdata/{qemuhotplug-hotplug-base+disk-scsi.xml => qemuhotplug-hotplug-base-live+disk-scsi.xml} (73%) rename tests/qemuhotplugtestdata/{qemuhotplug-hotplug-base+disk-usb.xml => qemuhotplug-hotplug-base-live+disk-usb.xml} (72%) copy tests/qemuhotplugtestdata/{qemuhotplug-hotplug-base+disk-virtio.xml => qemuhotplug-hotplug-base-live+disk-virtio.xml} (73%) rename tests/{qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml => qemuxml2argvdata/qemuxml2argv-console-compat-2-live.xml} (80%) rename tests/{qemuhotplugtestdata/qemuhotplug-hotplug-base+disk-virtio.xml => qemuxml2argvdata/qemuxml2argv-hotplug-base-live.xml} (71%) diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 689adc30aae5..1a61e85dc640 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -94,6 +94,9 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, (*vm)->def->id = QEMU_HOTPLUG_TEST_DOMAIN_ID; + if (qemuDomainSetPrivatePaths(&driver, *vm) < 0) + goto cleanup; + ret = 0; cleanup: return ret; @@ -179,7 +182,6 @@ testQemuHotplugCheckResult(virDomainObjPtr vm, char *actual; int ret; - vm->def->id = -1; actual = virDomainDefFormat(vm->def, driver.caps, VIR_DOMAIN_DEF_FORMAT_SECURE); if (!actual) @@ -426,62 +428,62 @@ mymain(void) /* Strange huh? Currently, only graphics can be updated :-P */ DO_TEST_UPDATE("disk-cdrom", "disk-cdrom-nochange", true, false, NULL); - DO_TEST_ATTACH("console-compat-2", "console-virtio", false, true, + DO_TEST_ATTACH("console-compat-2-live", "console-virtio", false, true, "chardev-add", "{\"return\": {\"pty\": \"/dev/pts/26\"}}", "device_add", QMP_OK); - DO_TEST_DETACH("console-compat-2", "console-virtio", false, false, + DO_TEST_DETACH("console-compat-2-live", "console-virtio", false, false, "device_del", QMP_OK, "chardev-remove", QMP_OK); - DO_TEST_ATTACH("hotplug-base", "disk-virtio", false, true, + DO_TEST_ATTACH("hotplug-base-live", "disk-virtio", false, true, "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); - DO_TEST_DETACH("hotplug-base", "disk-virtio", false, false, + DO_TEST_DETACH("hotplug-base-live", "disk-virtio", false, false, "device_del", QMP_OK, "human-monitor-command", HMP("")); - DO_TEST_ATTACH_EVENT("hotplug-base", "disk-virtio", false, true, + DO_TEST_ATTACH_EVENT("hotplug-base-live", "disk-virtio", false, true, "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); - DO_TEST_DETACH("hotplug-base", "disk-virtio", true, true, + DO_TEST_DETACH("hotplug-base-live", "disk-virtio", true, true, "device_del", QMP_OK, "human-monitor-command", HMP("")); - DO_TEST_DETACH("hotplug-base", "disk-virtio", false, false, + DO_TEST_DETACH("hotplug-base-live", "disk-virtio", false, false, "device_del", QMP_DEVICE_DELETED("virtio-disk4") QMP_OK, "human-monitor-command", HMP("")); - DO_TEST_ATTACH("hotplug-base", "disk-usb", false, true, + DO_TEST_ATTACH("hotplug-base-live", "disk-usb", false, true, "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); - DO_TEST_DETACH("hotplug-base", "disk-usb", false, false, + DO_TEST_DETACH("hotplug-base-live", "disk-usb", false, false, "device_del", QMP_OK, "human-monitor-command", HMP("")); - DO_TEST_ATTACH_EVENT("hotplug-base", "disk-usb", false, true, + DO_TEST_ATTACH_EVENT("hotplug-base-live", "disk-usb", false, true, "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); - DO_TEST_DETACH("hotplug-base", "disk-usb", true, true, + DO_TEST_DETACH("hotplug-base-live", "disk-usb", true, true, "device_del", QMP_OK, "human-monitor-command", HMP("")); - DO_TEST_DETACH("hotplug-base", "disk-usb", false, false, + DO_TEST_DETACH("hotplug-base-live", "disk-usb", false, false, "device_del", QMP_DEVICE_DELETED("usb-disk16") QMP_OK, "human-monitor-command", HMP("")); - DO_TEST_ATTACH("hotplug-base", "disk-scsi", false, true, + DO_TEST_ATTACH("hotplug-base-live", "disk-scsi", false, true, "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); - DO_TEST_DETACH("hotplug-base", "disk-scsi", false, false, + DO_TEST_DETACH("hotplug-base-live", "disk-scsi", false, false, "device_del", QMP_OK, "human-monitor-command", HMP("")); - DO_TEST_ATTACH_EVENT("hotplug-base", "disk-scsi", false, true, + DO_TEST_ATTACH_EVENT("hotplug-base-live", "disk-scsi", false, true, "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); - DO_TEST_DETACH("hotplug-base", "disk-scsi", true, true, + DO_TEST_DETACH("hotplug-base-live", "disk-scsi", true, true, "device_del", QMP_OK, "human-monitor-command", HMP("")); - DO_TEST_DETACH("hotplug-base", "disk-scsi", false, false, + DO_TEST_DETACH("hotplug-base-live", "disk-scsi", false, false, "device_del", QMP_DEVICE_DELETED("scsi0-0-0-5") QMP_OK, "human-monitor-command", HMP("")); diff --git a/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml b/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2-live+console-virtio.xml similarity index 79% copy from tests/qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml copy to tests/qemuhotplugtestdata/qemuhotplug-console-compat-2-live+console-virtio.xml index a2796ecdbb33..3495ee67b4ac 100644 --- a/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml +++ b/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2-live+console-virtio.xml @@ -1,4 +1,4 @@ -<domain type='kvm'> +<domain type='kvm' id='7'> <name>f17</name> <uuid>a1cd52eb-d37f-4717-fc6e-972f0774f4c9</uuid> <memory unit='KiB'>1048576</memory> @@ -29,24 +29,33 @@ <disk type='file' device='disk'> <driver name='qemu' type='qcow2' cache='none'/> <source file='/var/lib/libvirt/images/f17.qcow2'/> + <backingStore/> <target dev='vda' bus='virtio'/> + <alias name='virtio-disk0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </disk> <disk type='file' device='cdrom'> <driver name='qemu' type='raw' cache='none'/> <source file='/home/user/tmp/Fedora-17-x86_64-Live-KDE.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> + <alias name='ide0-1-0'/> <address type='drive' controller='0' bus='1' target='0' unit='0'/> </disk> <controller type='ide' index='0'> + <alias name='ide'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <controller type='usb' index='0'> + <alias name='usb'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> - <controller type='pci' index='0' model='pci-root'/> + <controller type='pci' index='0' model='pci-root'> + <alias name='pci'/> + </controller> <controller type='virtio-serial' index='0'> + <alias name='virtio-serial0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> </controller> <interface type='network'> @@ -57,44 +66,61 @@ <outbound average='4000' peak='8000' burst='1024'/> </bandwidth> <model type='virtio'/> + <alias name='net0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <serial type='pty'> <target type='isa-serial' port='0'/> + <alias name='serial0'/> </serial> <serial type='pty'> <target port='0'/> + <alias name='serial1'/> </serial> <serial type='tcp'> <source mode='bind' host='0.0.0.0' service='2445'/> <protocol type='raw'/> <target port='1'/> + <alias name='serial2'/> </serial> <console type='pty'> <target type='serial' port='0'/> + <alias name='serial0'/> </console> <console type='pty'> + <source path='/dev/pts/26'/> <target type='virtio' port='1'/> + <alias name='console1'/> </console> <channel type='unix'> <source mode='bind' path='/var/lib/libvirt/qemu/f17x86_64.agent'/> <target type='virtio' name='org.qemu.guest_agent.0'/> + <alias name='channel0'/> <address type='virtio-serial' controller='0' bus='0' port='1'/> </channel> - <input type='tablet' bus='usb'/> - <input type='mouse' bus='ps2'/> - <input type='keyboard' bus='ps2'/> + <input type='tablet' bus='usb'> + <alias name='input0'/> + </input> + <input type='mouse' bus='ps2'> + <alias name='input1'/> + </input> + <input type='keyboard' bus='ps2'> + <alias name='input2'/> + </input> <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'> <listen type='address' address='0.0.0.0'/> </graphics> <sound model='ich6'> + <alias name='sound0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </sound> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> + <alias name='video0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> </video> <memballoon model='virtio'> + <alias name='balloon0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> </memballoon> </devices> diff --git a/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+disk-scsi.xml b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+disk-scsi.xml similarity index 73% rename from tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+disk-scsi.xml rename to tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+disk-scsi.xml index cc970e9b3e82..2fbdee472f1f 100644 --- a/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+disk-scsi.xml +++ b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+disk-scsi.xml @@ -1,4 +1,4 @@ -<domain type='kvm'> +<domain type='kvm' id='7'> <name>hotplug</name> <uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid> <memory unit='KiB'>4194304</memory> @@ -22,27 +22,41 @@ <disk type='file' device='disk'> <driver name='qemu' type='raw' cache='none'/> <source file='/dev/null'/> + <backingStore/> <target dev='sdf' bus='scsi'/> <readonly/> <shareable/> + <alias name='scsi0-0-0-5'/> <address type='drive' controller='0' bus='0' target='0' unit='5'/> </disk> <controller type='usb' index='0'> + <alias name='usb'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> <controller type='ide' index='0'> + <alias name='ide'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <controller type='scsi' index='0' model='virtio-scsi'> + <alias name='scsi0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </controller> - <controller type='pci' index='0' model='pci-root'/> + <controller type='pci' index='0' model='pci-root'> + <alias name='pci'/> + </controller> <controller type='virtio-serial' index='0'> + <alias name='virtio-serial0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </controller> - <input type='mouse' bus='ps2'/> - <input type='keyboard' bus='ps2'/> - <memballoon model='none'/> + <input type='mouse' bus='ps2'> + <alias name='input0'/> + </input> + <input type='keyboard' bus='ps2'> + <alias name='input1'/> + </input> + <memballoon model='none'> + <alias name='balloon0'/> + </memballoon> </devices> <seclabel type='none' model='none'/> </domain> diff --git a/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+disk-usb.xml b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+disk-usb.xml similarity index 72% rename from tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+disk-usb.xml rename to tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+disk-usb.xml index edd04ed01bf4..41039a48c3d4 100644 --- a/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+disk-usb.xml +++ b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+disk-usb.xml @@ -1,4 +1,4 @@ -<domain type='kvm'> +<domain type='kvm' id='7'> <name>hotplug</name> <uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid> <memory unit='KiB'>4194304</memory> @@ -22,26 +22,40 @@ <disk type='file' device='disk'> <driver name='qemu' type='raw' cache='none'/> <source file='/dev/null'/> + <backingStore/> <target dev='sdq' bus='usb'/> <readonly/> <shareable/> + <alias name='usb-disk16'/> </disk> <controller type='usb' index='0'> + <alias name='usb'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> <controller type='ide' index='0'> + <alias name='ide'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <controller type='scsi' index='0' model='virtio-scsi'> + <alias name='scsi0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </controller> - <controller type='pci' index='0' model='pci-root'/> + <controller type='pci' index='0' model='pci-root'> + <alias name='pci'/> + </controller> <controller type='virtio-serial' index='0'> + <alias name='virtio-serial0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </controller> - <input type='mouse' bus='ps2'/> - <input type='keyboard' bus='ps2'/> - <memballoon model='none'/> + <input type='mouse' bus='ps2'> + <alias name='input0'/> + </input> + <input type='keyboard' bus='ps2'> + <alias name='input1'/> + </input> + <memballoon model='none'> + <alias name='balloon0'/> + </memballoon> </devices> <seclabel type='none' model='none'/> </domain> diff --git a/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+disk-virtio.xml b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+disk-virtio.xml similarity index 73% copy from tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+disk-virtio.xml copy to tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+disk-virtio.xml index b8a9c58bbd18..8954fb5898d3 100644 --- a/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+disk-virtio.xml +++ b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+disk-virtio.xml @@ -1,4 +1,4 @@ -<domain type='kvm'> +<domain type='kvm' id='7'> <name>hotplug</name> <uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid> <memory unit='KiB'>4194304</memory> @@ -22,27 +22,41 @@ <disk type='file' device='disk'> <driver name='qemu' type='raw' cache='none'/> <source file='/dev/null'/> + <backingStore/> <target dev='vde' bus='virtio'/> <readonly/> <shareable/> + <alias name='virtio-disk4'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </disk> <controller type='usb' index='0'> + <alias name='usb'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> <controller type='ide' index='0'> + <alias name='ide'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <controller type='scsi' index='0' model='virtio-scsi'> + <alias name='scsi0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </controller> - <controller type='pci' index='0' model='pci-root'/> + <controller type='pci' index='0' model='pci-root'> + <alias name='pci'/> + </controller> <controller type='virtio-serial' index='0'> + <alias name='virtio-serial0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </controller> - <input type='mouse' bus='ps2'/> - <input type='keyboard' bus='ps2'/> - <memballoon model='none'/> + <input type='mouse' bus='ps2'> + <alias name='input0'/> + </input> + <input type='keyboard' bus='ps2'> + <alias name='input1'/> + </input> + <memballoon model='none'> + <alias name='balloon0'/> + </memballoon> </devices> <seclabel type='none' model='none'/> </domain> diff --git a/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-2-live.xml similarity index 80% rename from tests/qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml rename to tests/qemuxml2argvdata/qemuxml2argv-console-compat-2-live.xml index a2796ecdbb33..b36af270c3ff 100644 --- a/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-2-live.xml @@ -1,4 +1,4 @@ -<domain type='kvm'> +<domain type='kvm' id='7'> <name>f17</name> <uuid>a1cd52eb-d37f-4717-fc6e-972f0774f4c9</uuid> <memory unit='KiB'>1048576</memory> @@ -29,24 +29,33 @@ <disk type='file' device='disk'> <driver name='qemu' type='qcow2' cache='none'/> <source file='/var/lib/libvirt/images/f17.qcow2'/> + <backingStore/> <target dev='vda' bus='virtio'/> + <alias name='virtio-disk0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </disk> <disk type='file' device='cdrom'> <driver name='qemu' type='raw' cache='none'/> <source file='/home/user/tmp/Fedora-17-x86_64-Live-KDE.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> + <alias name='ide0-1-0'/> <address type='drive' controller='0' bus='1' target='0' unit='0'/> </disk> <controller type='ide' index='0'> + <alias name='ide'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <controller type='usb' index='0'> + <alias name='usb'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> - <controller type='pci' index='0' model='pci-root'/> + <controller type='pci' index='0' model='pci-root'> + <alias name='pci'/> + </controller> <controller type='virtio-serial' index='0'> + <alias name='virtio-serial0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> </controller> <interface type='network'> @@ -57,44 +66,56 @@ <outbound average='4000' peak='8000' burst='1024'/> </bandwidth> <model type='virtio'/> + <alias name='net0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <serial type='pty'> <target type='isa-serial' port='0'/> + <alias name='serial0'/> </serial> <serial type='pty'> <target port='0'/> + <alias name='serial1'/> </serial> <serial type='tcp'> <source mode='bind' host='0.0.0.0' service='2445'/> <protocol type='raw'/> <target port='1'/> + <alias name='serial2'/> </serial> <console type='pty'> <target type='serial' port='0'/> - </console> - <console type='pty'> - <target type='virtio' port='1'/> + <alias name='serial0'/> </console> <channel type='unix'> <source mode='bind' path='/var/lib/libvirt/qemu/f17x86_64.agent'/> <target type='virtio' name='org.qemu.guest_agent.0'/> + <alias name='channel0'/> <address type='virtio-serial' controller='0' bus='0' port='1'/> </channel> - <input type='tablet' bus='usb'/> - <input type='mouse' bus='ps2'/> - <input type='keyboard' bus='ps2'/> + <input type='tablet' bus='usb'> + <alias name='input0'/> + </input> + <input type='mouse' bus='ps2'> + <alias name='input1'/> + </input> + <input type='keyboard' bus='ps2'> + <alias name='input2'/> + </input> <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'> <listen type='address' address='0.0.0.0'/> </graphics> <sound model='ich6'> + <alias name='sound0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </sound> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> + <alias name='video0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> </video> <memballoon model='virtio'> + <alias name='balloon0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> </memballoon> </devices> diff --git a/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+disk-virtio.xml b/tests/qemuxml2argvdata/qemuxml2argv-hotplug-base-live.xml similarity index 71% rename from tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+disk-virtio.xml rename to tests/qemuxml2argvdata/qemuxml2argv-hotplug-base-live.xml index b8a9c58bbd18..3f14e70a1b54 100644 --- a/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+disk-virtio.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-hotplug-base-live.xml @@ -1,4 +1,4 @@ -<domain type='kvm'> +<domain type='kvm' id='7'> <name>hotplug</name> <uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid> <memory unit='KiB'>4194304</memory> @@ -19,30 +19,34 @@ <on_crash>restart</on_crash> <devices> <emulator>/usr/libexec/qemu-kvm</emulator> - <disk type='file' device='disk'> - <driver name='qemu' type='raw' cache='none'/> - <source file='/dev/null'/> - <target dev='vde' bus='virtio'/> - <readonly/> - <shareable/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> - </disk> <controller type='usb' index='0'> + <alias name='usb'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> <controller type='ide' index='0'> + <alias name='ide'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <controller type='scsi' index='0' model='virtio-scsi'> + <alias name='scsi0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </controller> - <controller type='pci' index='0' model='pci-root'/> + <controller type='pci' index='0' model='pci-root'> + <alias name='pci'/> + </controller> <controller type='virtio-serial' index='0'> + <alias name='virtio-serial0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </controller> - <input type='mouse' bus='ps2'/> - <input type='keyboard' bus='ps2'/> - <memballoon model='none'/> + <input type='mouse' bus='ps2'> + <alias name='input0'/> + </input> + <input type='keyboard' bus='ps2'> + <alias name='input1'/> + </input> + <memballoon model='none'> + <alias name='balloon0'/> + </memballoon> </devices> <seclabel type='none' model='none'/> </domain> -- 2.8.3

On Sun, Jun 05, 2016 at 02:41:05 +0200, Martin Kletzander wrote:
Until now, the only hot thing in this test was the name. That's because we set the id to '-1' before every test. With this change, we test the hotplug on live domains as the name suggests and as it should be.
Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- tests/qemuhotplugtest.c | 38 ++++++++++++---------- ...tplug-console-compat-2-live+console-virtio.xml} | 36 +++++++++++++++++--- ...=> qemuhotplug-hotplug-base-live+disk-scsi.xml} | 24 +++++++++++--- ... => qemuhotplug-hotplug-base-live+disk-usb.xml} | 24 +++++++++++--- ... qemuhotplug-hotplug-base-live+disk-virtio.xml} | 24 +++++++++++--- .../qemuxml2argv-console-compat-2-live.xml} | 37 ++++++++++++++++----- .../qemuxml2argv-hotplug-base-live.xml} | 30 +++++++++-------- 7 files changed, 154 insertions(+), 59 deletions(-)
ACK

Since commit 714080791778e3dfbd484ccb3953bffd820b8ba9, qemu agent channel cannot be plugged in because we won't generate its path automatically. Let's not only fix that, but also add tests for it so next time it's checked for. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1322210 Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/qemu/qemu_hotplug.c | 3 ++ tests/qemuhotplugtest.c | 7 +++ .../qemuhotplug-hotplug-base+qemu-agent-detach.xml | 58 ++++++++++++++++++++++ .../qemuhotplug-hotplug-base+qemu-agent.xml | 58 ++++++++++++++++++++++ ...hotplug-hotplug-base-live+qemu-agent-detach.xml | 58 ++++++++++++++++++++++ .../qemuhotplug-hotplug-base-live+qemu-agent.xml | 58 ++++++++++++++++++++++ .../qemuhotplug-qemu-agent-detach.xml | 5 ++ .../qemuhotplugtestdata/qemuhotplug-qemu-agent.xml | 5 ++ 8 files changed, 252 insertions(+) create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+qemu-agent-detach.xml create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+qemu-agent.xml create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+qemu-agent-detach.xml create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+qemu-agent.xml create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-qemu-agent-detach.xml create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-qemu-agent.xml diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 6ce0a84cfae2..582a0e69a41f 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1502,6 +1502,9 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver, char *charAlias = NULL; bool need_release = false; + if (qemuDomainPrepareChannel(chr, priv->channelTargetDir) < 0) + goto cleanup; + if (qemuAssignDeviceChrAlias(vmdef, chr, -1) < 0) goto cleanup; diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 1a61e85dc640..6458e6b332b3 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -487,6 +487,13 @@ mymain(void) "device_del", QMP_DEVICE_DELETED("scsi0-0-0-5") QMP_OK, "human-monitor-command", HMP("")); + DO_TEST_ATTACH("hotplug-base-live", "qemu-agent", false, true, + "chardev-add", QMP_OK, + "device_add", QMP_OK); + DO_TEST_DETACH("hotplug-base-live", "qemu-agent-detach", false, false, + "device_del", QMP_OK, + "chardev-remove", QMP_OK); + qemuTestDriverFree(&driver); return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+qemu-agent-detach.xml b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+qemu-agent-detach.xml new file mode 100644 index 000000000000..2c449f1d49cd --- /dev/null +++ b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+qemu-agent-detach.xml @@ -0,0 +1,58 @@ +<domain type='kvm' id='7'> + <name>hotplug</name> + <uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid> + <memory unit='KiB'>4194304</memory> + <currentMemory unit='KiB'>4194304</currentMemory> + <vcpu placement='static'>4</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/libexec/qemu-kvm</emulator> + <controller type='usb' index='0'> + <alias name='usb'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <alias name='ide'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='scsi' index='0' model='virtio-scsi'> + <alias name='scsi0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </controller> + <controller type='pci' index='0' model='pci-root'> + <alias name='pci'/> + </controller> + <controller type='virtio-serial' index='0'> + <alias name='virtio-serial0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + </controller> + <channel type='unix'> + <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/domain-7-hotplug/org.qemu.guest_agent.0'/> + <target type='virtio' name='org.qemu.guest_agent.0'/> + <alias name='channel0'/> + <address type='virtio-serial' controller='0' bus='0' port='1'/> + </channel> + <input type='mouse' bus='ps2'> + <alias name='input0'/> + </input> + <input type='keyboard' bus='ps2'> + <alias name='input1'/> + </input> + <memballoon model='none'> + <alias name='balloon0'/> + </memballoon> + </devices> + <seclabel type='none' model='none'/> +</domain> diff --git a/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+qemu-agent.xml b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+qemu-agent.xml new file mode 100644 index 000000000000..47fc9708ac43 --- /dev/null +++ b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+qemu-agent.xml @@ -0,0 +1,58 @@ +<domain type='kvm' id='7'> + <name>hotplug</name> + <uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid> + <memory unit='KiB'>4194304</memory> + <currentMemory unit='KiB'>4194304</currentMemory> + <vcpu placement='static'>4</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/libexec/qemu-kvm</emulator> + <controller type='usb' index='0'> + <alias name='usb'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <alias name='ide'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='scsi' index='0' model='virtio-scsi'> + <alias name='scsi0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </controller> + <controller type='pci' index='0' model='pci-root'> + <alias name='pci'/> + </controller> + <controller type='virtio-serial' index='0'> + <alias name='virtio-serial0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + </controller> + <channel type='unix'> + <source mode='bind' path='/tmp/channel/domain-7-hotplug/org.qemu.guest_agent.0'/> + <target type='virtio' name='org.qemu.guest_agent.0'/> + <alias name='channel0'/> + <address type='virtio-serial' controller='0' bus='0' port='1'/> + </channel> + <input type='mouse' bus='ps2'> + <alias name='input0'/> + </input> + <input type='keyboard' bus='ps2'> + <alias name='input1'/> + </input> + <memballoon model='none'> + <alias name='balloon0'/> + </memballoon> + </devices> + <seclabel type='none' model='none'/> +</domain> diff --git a/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+qemu-agent-detach.xml b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+qemu-agent-detach.xml new file mode 100644 index 000000000000..2c449f1d49cd --- /dev/null +++ b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+qemu-agent-detach.xml @@ -0,0 +1,58 @@ +<domain type='kvm' id='7'> + <name>hotplug</name> + <uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid> + <memory unit='KiB'>4194304</memory> + <currentMemory unit='KiB'>4194304</currentMemory> + <vcpu placement='static'>4</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/libexec/qemu-kvm</emulator> + <controller type='usb' index='0'> + <alias name='usb'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <alias name='ide'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='scsi' index='0' model='virtio-scsi'> + <alias name='scsi0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </controller> + <controller type='pci' index='0' model='pci-root'> + <alias name='pci'/> + </controller> + <controller type='virtio-serial' index='0'> + <alias name='virtio-serial0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + </controller> + <channel type='unix'> + <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/domain-7-hotplug/org.qemu.guest_agent.0'/> + <target type='virtio' name='org.qemu.guest_agent.0'/> + <alias name='channel0'/> + <address type='virtio-serial' controller='0' bus='0' port='1'/> + </channel> + <input type='mouse' bus='ps2'> + <alias name='input0'/> + </input> + <input type='keyboard' bus='ps2'> + <alias name='input1'/> + </input> + <memballoon model='none'> + <alias name='balloon0'/> + </memballoon> + </devices> + <seclabel type='none' model='none'/> +</domain> diff --git a/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+qemu-agent.xml b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+qemu-agent.xml new file mode 100644 index 000000000000..47fc9708ac43 --- /dev/null +++ b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+qemu-agent.xml @@ -0,0 +1,58 @@ +<domain type='kvm' id='7'> + <name>hotplug</name> + <uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid> + <memory unit='KiB'>4194304</memory> + <currentMemory unit='KiB'>4194304</currentMemory> + <vcpu placement='static'>4</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/libexec/qemu-kvm</emulator> + <controller type='usb' index='0'> + <alias name='usb'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <alias name='ide'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='scsi' index='0' model='virtio-scsi'> + <alias name='scsi0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </controller> + <controller type='pci' index='0' model='pci-root'> + <alias name='pci'/> + </controller> + <controller type='virtio-serial' index='0'> + <alias name='virtio-serial0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + </controller> + <channel type='unix'> + <source mode='bind' path='/tmp/channel/domain-7-hotplug/org.qemu.guest_agent.0'/> + <target type='virtio' name='org.qemu.guest_agent.0'/> + <alias name='channel0'/> + <address type='virtio-serial' controller='0' bus='0' port='1'/> + </channel> + <input type='mouse' bus='ps2'> + <alias name='input0'/> + </input> + <input type='keyboard' bus='ps2'> + <alias name='input1'/> + </input> + <memballoon model='none'> + <alias name='balloon0'/> + </memballoon> + </devices> + <seclabel type='none' model='none'/> +</domain> diff --git a/tests/qemuhotplugtestdata/qemuhotplug-qemu-agent-detach.xml b/tests/qemuhotplugtestdata/qemuhotplug-qemu-agent-detach.xml new file mode 100644 index 000000000000..1ae1468cf605 --- /dev/null +++ b/tests/qemuhotplugtestdata/qemuhotplug-qemu-agent-detach.xml @@ -0,0 +1,5 @@ + <channel type='unix'> + <source mode='bind' path='/tmp/channel/domain-7-hotplug/org.qemu.guest_agent.0'/> + <target type='virtio' name='org.qemu.guest_agent.0'/> + <address type='virtio-serial' controller='0' bus='0' port='1'/> + </channel> diff --git a/tests/qemuhotplugtestdata/qemuhotplug-qemu-agent.xml b/tests/qemuhotplugtestdata/qemuhotplug-qemu-agent.xml new file mode 100644 index 000000000000..f0e90dea3cc2 --- /dev/null +++ b/tests/qemuhotplugtestdata/qemuhotplug-qemu-agent.xml @@ -0,0 +1,5 @@ + <channel type='unix'> + <source mode='bind'/> + <target type='virtio' name='org.qemu.guest_agent.0'/> + <address type='virtio-serial' controller='0' bus='0' port='1'/> + </channel> -- 2.8.3

On Sun, Jun 05, 2016 at 02:41:06 +0200, Martin Kletzander wrote:
Since commit 714080791778e3dfbd484ccb3953bffd820b8ba9, qemu agent channel cannot be plugged in because we won't generate its path automatically. Let's not only fix that, but also add tests for it so next time it's checked for.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1322210
Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/qemu/qemu_hotplug.c | 3 ++ tests/qemuhotplugtest.c | 7 +++ .../qemuhotplug-hotplug-base+qemu-agent-detach.xml | 58 ++++++++++++++++++++++ .../qemuhotplug-hotplug-base+qemu-agent.xml | 58 ++++++++++++++++++++++ ...hotplug-hotplug-base-live+qemu-agent-detach.xml | 58 ++++++++++++++++++++++ .../qemuhotplug-hotplug-base-live+qemu-agent.xml | 58 ++++++++++++++++++++++ .../qemuhotplug-qemu-agent-detach.xml | 5 ++ .../qemuhotplugtestdata/qemuhotplug-qemu-agent.xml | 5 ++ 8 files changed, 252 insertions(+) create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+qemu-agent-detach.xml create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+qemu-agent.xml create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+qemu-agent-detach.xml create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+qemu-agent.xml create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-qemu-agent-detach.xml create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-qemu-agent.xml
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 6ce0a84cfae2..582a0e69a41f 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1502,6 +1502,9 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver, char *charAlias = NULL; bool need_release = false;
+ if (qemuDomainPrepareChannel(chr, priv->channelTargetDir) < 0)
At this point it's not certain that this is a channel. This can be any other character device.
+ goto cleanup; + if (qemuAssignDeviceChrAlias(vmdef, chr, -1) < 0) goto cleanup;
ACK with the check above fixed.
participants (2)
-
Martin Kletzander
-
Peter Krempa