From 326e5941cd6ac00a9aa4149872f71c2403f25db4 Mon Sep 17 00:00:00 2001 From: Martin Kletzander Date: Wed, 30 Mar 2016 16:43:28 +0200 Subject: [PATCH] qemu: Generate channel target paths on hotplug as well 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 --- src/qemu/qemu_hotplug.c | 4 ++ tests/qemuhotplugtest.c | 7 +++ ...hotplug-hotplug-base+qemu-agent-detach.xml | 58 +++++++++++++++++++ .../qemuhotplug-hotplug-base+qemu-agent.xml | 58 +++++++++++++++++++ ...ug-hotplug-base-live+qemu-agent-detach.xml | 58 +++++++++++++++++++ ...muhotplug-hotplug-base-live+qemu-agent.xml | 58 +++++++++++++++++++ .../qemuhotplug-qemu-agent-detach.xml | 5 ++ .../qemuhotplug-qemu-agent.xml | 5 ++ 8 files changed, 253 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 6ce0a84cfa..6fbeb32253 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1502,6 +1502,10 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver, char *charAlias = NULL; bool need_release = false; + if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL && + 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 5eb34c04b3..13055ab380 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 0000000000..2c449f1d49 --- /dev/null +++ b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+qemu-agent-detach.xml @@ -0,0 +1,58 @@ + + hotplug + d091ea82-29e6-2e34-3005-f02617b36e87 + 4194304 + 4194304 + 4 + + hvm + + + + + + + + + destroy + restart + restart + + /usr/libexec/qemu-kvm + + +
+ + + +
+ + + +
+ + + + + + +
+ + + + + +
+ + + + + + + + + + + + + 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 0000000000..47fc9708ac --- /dev/null +++ b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+qemu-agent.xml @@ -0,0 +1,58 @@ + + hotplug + d091ea82-29e6-2e34-3005-f02617b36e87 + 4194304 + 4194304 + 4 + + hvm + + + + + + + + + destroy + restart + restart + + /usr/libexec/qemu-kvm + + +
+ + + +
+ + + +
+ + + + + + +
+ + + + + +
+ + + + + + + + + + + + + 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 0000000000..2c449f1d49 --- /dev/null +++ b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+qemu-agent-detach.xml @@ -0,0 +1,58 @@ + + hotplug + d091ea82-29e6-2e34-3005-f02617b36e87 + 4194304 + 4194304 + 4 + + hvm + + + + + + + + + destroy + restart + restart + + /usr/libexec/qemu-kvm + + +
+ + + +
+ + + +
+ + + + + + +
+ + + + + +
+ + + + + + + + + + + + + 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 0000000000..47fc9708ac --- /dev/null +++ b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+qemu-agent.xml @@ -0,0 +1,58 @@ + + hotplug + d091ea82-29e6-2e34-3005-f02617b36e87 + 4194304 + 4194304 + 4 + + hvm + + + + + + + + + destroy + restart + restart + + /usr/libexec/qemu-kvm + + +
+ + + +
+ + + +
+ + + + + + +
+ + + + + +
+ + + + + + + + + + + + + diff --git a/tests/qemuhotplugtestdata/qemuhotplug-qemu-agent-detach.xml b/tests/qemuhotplugtestdata/qemuhotplug-qemu-agent-detach.xml new file mode 100644 index 0000000000..1ae1468cf6 --- /dev/null +++ b/tests/qemuhotplugtestdata/qemuhotplug-qemu-agent-detach.xml @@ -0,0 +1,5 @@ + + + +
+ diff --git a/tests/qemuhotplugtestdata/qemuhotplug-qemu-agent.xml b/tests/qemuhotplugtestdata/qemuhotplug-qemu-agent.xml new file mode 100644 index 0000000000..f0e90dea3c --- /dev/null +++ b/tests/qemuhotplugtestdata/qemuhotplug-qemu-agent.xml @@ -0,0 +1,5 @@ + + + +
+