On Thu, Aug 11, 2011 at 08:39:23PM -0600, Eric Blake wrote:
We forgot to add virDomainUndefineFlags for a couple of hypervisors.
This wires up trivial versions (since neither hypervisor supports
managed save yet, they do not need to support any flags).
* src/vbox/vbox_tmpl.c (vboxDomainCreateXML): Update caller.
(vboxDomainUndefine): Move guts...
(vboxDomainUndefineFlags): ...to new function.
* src/xenapi/xenapi_driver.c (xenapiDomainUndefine)
(xenapiDomainUndefineFlags): Likewise.
---
I'm still debating on whether implementations that lack managed
save should trivially support 'undefine --managed-save' (there's
none to undefine), instead of the current behavior of rejecting
it as an unknown flag. But that's an independent question.
src/vbox/vbox_tmpl.c | 14 +++++++++++---
src/xenapi/xenapi_driver.c | 13 +++++++++++--
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 5c71729..822e899 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -251,7 +251,7 @@ static vboxGlobalData *g_pVBoxGlobalData = NULL;
static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml);
static int vboxDomainCreate(virDomainPtr dom);
-static int vboxDomainUndefine(virDomainPtr dom);
+static int vboxDomainUndefineFlags(virDomainPtr dom, unsigned int flags);
static void vboxDriverLock(vboxGlobalData *data) {
virMutexLock(&data->lock);
@@ -1193,7 +1193,7 @@ static virDomainPtr vboxDomainCreateXML(virConnectPtr conn, const
char *xml,
return NULL;
if (vboxDomainCreate(dom) < 0) {
- vboxDomainUndefine(dom);
+ vboxDomainUndefineFlags(dom, 0);
virUnrefDomain(dom);
return NULL;
}
@@ -4973,7 +4973,7 @@ cleanup:
}
static int
-vboxDomainUndefine(virDomainPtr dom)
+vboxDomainUndefineFlags(virDomainPtr dom, unsigned int flags)
{
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
@@ -4982,6 +4982,7 @@ vboxDomainUndefine(virDomainPtr dom)
#if VBOX_API_VERSION >= 4000
vboxArray media = VBOX_ARRAY_INITIALIZER;
#endif
+ virCheckFlags(0, -1);
vboxIIDFromUUID(&iid, dom->uuid);
@@ -5131,6 +5132,12 @@ vboxDomainUndefine(virDomainPtr dom)
return ret;
}
+static int
+vboxDomainUndefine(virDomainPtr dom)
+{
+ return vboxDomainUndefineFlags(dom, 0);
+}
+
static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
const char *xml,
int mediaChangeOnly ATTRIBUTE_UNUSED) {
@@ -8806,6 +8813,7 @@ virDriver NAME(Driver) = {
.domainCreateWithFlags = vboxDomainCreateWithFlags, /* 0.8.2 */
.domainDefineXML = vboxDomainDefineXML, /* 0.6.3 */
.domainUndefine = vboxDomainUndefine, /* 0.6.3 */
+ .domainUndefineFlags = vboxDomainUndefineFlags, /* 0.9.5 */
.domainAttachDevice = vboxDomainAttachDevice, /* 0.6.3 */
.domainAttachDeviceFlags = vboxDomainAttachDeviceFlags, /* 0.7.7 */
.domainDetachDevice = vboxDomainDetachDevice, /* 0.6.3 */
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index d40bc3e..80a706a 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -1696,17 +1696,19 @@ xenapiDomainDefineXML (virConnectPtr conn, const char *xml)
}
/*
- * xenapiDomainUndefine
+ * xenapiDomainUndefineFlags
*
* destroys a domain
* Return 0 on success or -1 in case of error
*/
static int
-xenapiDomainUndefine (virDomainPtr dom)
+xenapiDomainUndefineFlags(virDomainPtr dom, unsigned int flags)
{
struct xen_vm_set *vms;
xen_vm vm;
xen_session *session = ((struct _xenapiPrivate
*)(dom->conn->privateData))->session;
+ virCheckFlags(0, -1);
+
if (xen_vm_get_by_name_label(session, &vms, dom->name) &&
vms->size > 0) {
if (vms->size != 1) {
xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
@@ -1728,6 +1730,12 @@ xenapiDomainUndefine (virDomainPtr dom)
return -1;
}
+static int
+xenapiDomainUndefine(virDomainPtr dom)
+{
+ return xenapiDomainUndefineFlags(dom, 0);
+}
+
/*
* xenapiDomainGetAutostart
*
@@ -1922,6 +1930,7 @@ static virDriver xenapiDriver = {
.domainCreateWithFlags = xenapiDomainCreateWithFlags, /* 0.8.2 */
.domainDefineXML = xenapiDomainDefineXML, /* 0.8.0 */
.domainUndefine = xenapiDomainUndefine, /* 0.8.0 */
+ .domainUndefineFlags = xenapiDomainUndefineFlags, /* 0.9.5 */
.domainGetAutostart = xenapiDomainGetAutostart, /* 0.8.0 */
.domainSetAutostart = xenapiDomainSetAutostart, /* 0.8.0 */
.domainGetSchedulerType = xenapiDomainGetSchedulerType, /* 0.8.0 */
ACK,
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit
http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine
http://rpmfind.net/
http://veillard.com/ | virtualization library
http://libvirt.org/