|
|
9119d9 |
From afcec1b837a1be463234ead731483a28f9d8a428 Mon Sep 17 00:00:00 2001
|
|
|
9119d9 |
Message-Id: <afcec1b837a1be463234ead731483a28f9d8a428@dist-git>
|
|
|
9119d9 |
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
|
|
|
9119d9 |
Date: Mon, 19 Jan 2015 10:48:33 +0100
|
|
|
9119d9 |
Subject: [PATCH] Fix vmdef usage after domain crash in monitor on device
|
|
|
9119d9 |
attach
|
|
|
9119d9 |
MIME-Version: 1.0
|
|
|
9119d9 |
Content-Type: text/plain; charset=UTF-8
|
|
|
9119d9 |
Content-Transfer-Encoding: 8bit
|
|
|
9119d9 |
|
|
|
9119d9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1161024
|
|
|
9119d9 |
|
|
|
9119d9 |
If the domain crashed while we were in monitor,
|
|
|
9119d9 |
we cannot rely on the REALLOC done on live definition,
|
|
|
9119d9 |
since vm->def now points to the persistent definition.
|
|
|
9119d9 |
Skip adding the attached devices to domain definition
|
|
|
9119d9 |
if the domain crashed.
|
|
|
9119d9 |
|
|
|
9119d9 |
In AttachChrDevice, the chardev was already added to the
|
|
|
9119d9 |
live definition and freed by qemuProcessStop in the case
|
|
|
9119d9 |
of a crash. Skip the device removal in that case.
|
|
|
9119d9 |
|
|
|
9119d9 |
Also skip audit if the domain crashed in the meantime.
|
|
|
9119d9 |
|
|
|
9119d9 |
(cherry picked from commit 3070bc8ee52efed073e5d351bfdb1072bbc6e303)
|
|
|
9119d9 |
Signed-off-by: Ján Tomko <jtomko@redhat.com>
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
---
|
|
|
9119d9 |
src/qemu/qemu_hotplug.c | 69 +++++++++++++++++++++++++++++++++++++------------
|
|
|
9119d9 |
1 file changed, 52 insertions(+), 17 deletions(-)
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
|
|
|
9119d9 |
index c78cc4e..8a3eb27 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_hotplug.c
|
|
|
9119d9 |
+++ b/src/qemu/qemu_hotplug.c
|
|
|
9119d9 |
@@ -390,7 +390,11 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
|
|
|
9119d9 |
memcpy(&disk->info.addr.pci, &guestAddr, sizeof(guestAddr));
|
|
|
9119d9 |
}
|
|
|
9119d9 |
}
|
|
|
9119d9 |
- qemuDomainObjExitMonitor(driver, vm);
|
|
|
9119d9 |
+ if (qemuDomainObjExitMonitor(driver, vm) < 0) {
|
|
|
9119d9 |
+ releaseaddr = false;
|
|
|
9119d9 |
+ ret = -1;
|
|
|
9119d9 |
+ goto error;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
|
|
|
9119d9 |
virDomainAuditDisk(vm, NULL, disk->src, "attach", ret >= 0);
|
|
|
9119d9 |
|
|
|
9119d9 |
@@ -485,7 +489,11 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver,
|
|
|
9119d9 |
type,
|
|
|
9119d9 |
&controller->info.addr.pci);
|
|
|
9119d9 |
}
|
|
|
9119d9 |
- qemuDomainObjExitMonitor(driver, vm);
|
|
|
9119d9 |
+ if (qemuDomainObjExitMonitor(driver, vm) < 0) {
|
|
|
9119d9 |
+ releaseaddr = false;
|
|
|
9119d9 |
+ ret = -1;
|
|
|
9119d9 |
+ goto cleanup;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
|
|
|
9119d9 |
if (ret == 0) {
|
|
|
9119d9 |
if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
|
|
|
9119d9 |
@@ -636,7 +644,10 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn,
|
|
|
9119d9 |
disk->info.addr.drive.unit = driveAddr.unit;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
}
|
|
|
9119d9 |
- qemuDomainObjExitMonitor(driver, vm);
|
|
|
9119d9 |
+ if (qemuDomainObjExitMonitor(driver, vm) < 0) {
|
|
|
9119d9 |
+ ret = -1;
|
|
|
9119d9 |
+ goto error;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
|
|
|
9119d9 |
virDomainAuditDisk(vm, NULL, disk->src, "attach", ret >= 0);
|
|
|
9119d9 |
|
|
|
9119d9 |
@@ -716,7 +727,10 @@ qemuDomainAttachUSBMassstorageDevice(virConnectPtr conn,
|
|
|
9119d9 |
} else {
|
|
|
9119d9 |
ret = qemuMonitorAddUSBDisk(priv->mon, src);
|
|
|
9119d9 |
}
|
|
|
9119d9 |
- qemuDomainObjExitMonitor(driver, vm);
|
|
|
9119d9 |
+ if (qemuDomainObjExitMonitor(driver, vm) < 0) {
|
|
|
9119d9 |
+ ret = -1;
|
|
|
9119d9 |
+ goto error;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
|
|
|
9119d9 |
virDomainAuditDisk(vm, NULL, disk->src, "attach", ret >= 0);
|
|
|
9119d9 |
|
|
|
9119d9 |
@@ -1277,7 +1291,8 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
|
|
|
9119d9 |
qemuDomainObjEnterMonitor(driver, vm);
|
|
|
9119d9 |
ret = qemuMonitorAddDeviceWithFd(priv->mon, devstr,
|
|
|
9119d9 |
configfd, configfd_name);
|
|
|
9119d9 |
- qemuDomainObjExitMonitor(driver, vm);
|
|
|
9119d9 |
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
|
|
9119d9 |
+ goto error;
|
|
|
9119d9 |
} else {
|
|
|
9119d9 |
virDevicePCIAddressPtr guestAddr = &hostdev->info->addr.pci;
|
|
|
9119d9 |
virDevicePCIAddressPtr hostAddr = &hostdev->source.subsys.u.pci.addr;
|
|
|
9119d9 |
@@ -1293,7 +1308,8 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
|
|
|
9119d9 |
|
|
|
9119d9 |
qemuDomainObjEnterMonitor(driver, vm);
|
|
|
9119d9 |
ret = qemuMonitorAddPCIHostDevice(priv->mon, hostAddr, guestAddr);
|
|
|
9119d9 |
- qemuDomainObjExitMonitor(driver, vm);
|
|
|
9119d9 |
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
|
|
9119d9 |
+ goto error;
|
|
|
9119d9 |
|
|
|
9119d9 |
hostdev->info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
@@ -1353,12 +1369,11 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriverPtr driver,
|
|
|
9119d9 |
goto error;
|
|
|
9119d9 |
|
|
|
9119d9 |
qemuDomainObjEnterMonitor(driver, vm);
|
|
|
9119d9 |
- if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE))
|
|
|
9119d9 |
- ret = qemuMonitorAddDevice(priv->mon, devstr);
|
|
|
9119d9 |
- else
|
|
|
9119d9 |
+ ret = qemuMonitorAddDevice(priv->mon, devstr);
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
|
|
9119d9 |
goto error;
|
|
|
9119d9 |
|
|
|
9119d9 |
- qemuDomainObjExitMonitor(driver, vm);
|
|
|
9119d9 |
virDomainAuditRedirdev(vm, redirdev, "attach", ret == 0);
|
|
|
9119d9 |
if (ret < 0)
|
|
|
9119d9 |
goto error;
|
|
|
9119d9 |
@@ -1480,17 +1495,29 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
|
|
|
9119d9 |
|
|
|
9119d9 |
qemuDomainObjEnterMonitor(driver, vm);
|
|
|
9119d9 |
if (qemuMonitorAttachCharDev(priv->mon, charAlias, &chr->source) < 0) {
|
|
|
9119d9 |
- qemuDomainObjExitMonitor(driver, vm);
|
|
|
9119d9 |
+ if (qemuDomainObjExitMonitor(driver, vm) < 0) {
|
|
|
9119d9 |
+ need_remove = false;
|
|
|
9119d9 |
+ ret = -1;
|
|
|
9119d9 |
+ goto cleanup;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
goto audit;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
if (devstr && qemuMonitorAddDevice(priv->mon, devstr) < 0) {
|
|
|
9119d9 |
/* detach associated chardev on error */
|
|
|
9119d9 |
qemuMonitorDetachCharDev(priv->mon, charAlias);
|
|
|
9119d9 |
- qemuDomainObjExitMonitor(driver, vm);
|
|
|
9119d9 |
+ if (qemuDomainObjExitMonitor(driver, vm) < 0) {
|
|
|
9119d9 |
+ need_remove = false;
|
|
|
9119d9 |
+ ret = -1;
|
|
|
9119d9 |
+ goto cleanup;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
goto audit;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
- qemuDomainObjExitMonitor(driver, vm);
|
|
|
9119d9 |
+ if (qemuDomainObjExitMonitor(driver, vm) < 0) {
|
|
|
9119d9 |
+ need_remove = false;
|
|
|
9119d9 |
+ ret = -1;
|
|
|
9119d9 |
+ goto cleanup;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
|
|
|
9119d9 |
ret = 0;
|
|
|
9119d9 |
audit:
|
|
|
9119d9 |
@@ -1546,7 +1573,10 @@ qemuDomainAttachHostUSBDevice(virQEMUDriverPtr driver,
|
|
|
9119d9 |
ret = qemuMonitorAddUSBDeviceExact(priv->mon,
|
|
|
9119d9 |
hostdev->source.subsys.u.usb.bus,
|
|
|
9119d9 |
hostdev->source.subsys.u.usb.device);
|
|
|
9119d9 |
- qemuDomainObjExitMonitor(driver, vm);
|
|
|
9119d9 |
+ if (qemuDomainObjExitMonitor(driver, vm) < 0) {
|
|
|
9119d9 |
+ ret = -1;
|
|
|
9119d9 |
+ goto cleanup;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
virDomainAuditHostdev(vm, hostdev, "attach", ret == 0);
|
|
|
9119d9 |
if (ret < 0)
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
@@ -1649,7 +1679,10 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn,
|
|
|
9119d9 |
}
|
|
|
9119d9 |
}
|
|
|
9119d9 |
}
|
|
|
9119d9 |
- qemuDomainObjExitMonitor(driver, vm);
|
|
|
9119d9 |
+ if (qemuDomainObjExitMonitor(driver, vm) < 0) {
|
|
|
9119d9 |
+ ret = -1;
|
|
|
9119d9 |
+ goto cleanup;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
|
|
|
9119d9 |
virDomainAuditHostdev(vm, hostdev, "attach", ret == 0);
|
|
|
9119d9 |
if (ret < 0)
|
|
|
9119d9 |
@@ -1895,7 +1928,8 @@ int qemuDomainChangeNetLinkState(virQEMUDriverPtr driver,
|
|
|
9119d9 |
dev->linkstate = linkstate;
|
|
|
9119d9 |
|
|
|
9119d9 |
cleanup:
|
|
|
9119d9 |
- qemuDomainObjExitMonitor(driver, vm);
|
|
|
9119d9 |
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
|
|
9119d9 |
+ return -1;
|
|
|
9119d9 |
|
|
|
9119d9 |
return ret;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
@@ -3661,7 +3695,8 @@ qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver,
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
end_job:
|
|
|
9119d9 |
- qemuDomainObjExitMonitor(driver, vm);
|
|
|
9119d9 |
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
|
|
9119d9 |
+ ret = -1;
|
|
|
9119d9 |
cleanup:
|
|
|
9119d9 |
virObjectUnref(cfg);
|
|
|
9119d9 |
return ret;
|
|
|
9119d9 |
--
|
|
|
9119d9 |
2.2.1
|
|
|
9119d9 |
|