86 lines
2.7 KiB
Diff
86 lines
2.7 KiB
Diff
From a521796bac21f0c8af38a8551a420d87b61c7a9a Mon Sep 17 00:00:00 2001
|
|
From: Cole Robinson <crobinso@redhat.com>
|
|
Date: Wed, 6 May 2009 14:20:34 +0000
|
|
Subject: [PATCH] Refresh QEMU driver capabilities for each getCapabilities call.
|
|
|
|
Also fix up a couple issues where caps are accessed without locking
|
|
the driver structure.
|
|
|
|
(cherry picked from commit 4f107590243631869677ddea2bb667db4a1282a6)
|
|
|
|
Fedora-patch: libvirt-0.6.3-refresh-qemu-caps.patch
|
|
---
|
|
src/qemu_driver.c | 28 ++++++++++++++++++++--------
|
|
1 files changed, 20 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
|
|
index 162d072..4752a64 100644
|
|
--- a/src/qemu_driver.c
|
|
+++ b/src/qemu_driver.c
|
|
@@ -1872,10 +1872,12 @@ static int qemudGetNodeInfo(virConnectPtr conn,
|
|
|
|
static char *qemudGetCapabilities(virConnectPtr conn) {
|
|
struct qemud_driver *driver = conn->privateData;
|
|
- char *xml;
|
|
+ char *xml = NULL;
|
|
|
|
qemuDriverLock(driver);
|
|
- if ((xml = virCapabilitiesFormatXML(driver->caps)) == NULL)
|
|
+ virCapabilitiesFree(qemu_driver->caps);
|
|
+ if ((qemu_driver->caps = qemudCapsInit()) == NULL ||
|
|
+ (xml = virCapabilitiesFormatXML(driver->caps)) == NULL)
|
|
virReportOOMError(conn);
|
|
qemuDriverUnlock(driver);
|
|
|
|
@@ -3142,20 +3144,26 @@ cleanup:
|
|
return ret;
|
|
}
|
|
|
|
-static int qemudNodeGetSecurityModel(virConnectPtr conn, virSecurityModelPtr secmodel)
|
|
+static int qemudNodeGetSecurityModel(virConnectPtr conn,
|
|
+ virSecurityModelPtr secmodel)
|
|
{
|
|
struct qemud_driver *driver = (struct qemud_driver *)conn->privateData;
|
|
char *p;
|
|
+ int ret = 0;
|
|
|
|
- if (!driver->securityDriver)
|
|
- return -2;
|
|
+ qemuDriverLock(driver);
|
|
+ if (!driver->securityDriver) {
|
|
+ ret = -2;
|
|
+ goto cleanup;
|
|
+ }
|
|
|
|
p = driver->caps->host.secModel.model;
|
|
if (strlen(p) >= VIR_SECURITY_MODEL_BUFLEN-1) {
|
|
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
|
_("security model string exceeds max %d bytes"),
|
|
VIR_SECURITY_MODEL_BUFLEN-1);
|
|
- return -1;
|
|
+ ret = -1;
|
|
+ goto cleanup;
|
|
}
|
|
strcpy(secmodel->model, p);
|
|
|
|
@@ -3164,10 +3172,14 @@ static int qemudNodeGetSecurityModel(virConnectPtr conn, virSecurityModelPtr sec
|
|
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
|
_("security DOI string exceeds max %d bytes"),
|
|
VIR_SECURITY_DOI_BUFLEN-1);
|
|
- return -1;
|
|
+ ret = -1;
|
|
+ goto cleanup;
|
|
}
|
|
strcpy(secmodel->doi, p);
|
|
- return 0;
|
|
+
|
|
+cleanup:
|
|
+ qemuDriverUnlock(driver);
|
|
+ return ret;
|
|
}
|
|
|
|
/* TODO: check seclabel restore */
|
|
--
|
|
1.6.2.5
|
|
|