[libvirt] [PATCH 00/12] New API: virDominShutdownFlags

This series creates new API which adds flags to virDomainShutdown. As mentioned here many times, it is a bad luck all APIs don't have flags parameter. Parameter for this might be needed to select different ways of shutting down a domain. Currently, no new functionality is implemented, but this paves the way for creating multiple ways of domain shutting down. Therefore, calling this new API is the same as calling its predecessor. Michal Privoznik (12): shutdown: Define new public API virDomainShutdownFlags shutdown: Wire up the remote protocol shutdown: Implement internal API for qemu driver shutdown: Implement internal API for ESX driver shutdown: Implement internal API for libxl driver shutdown: Implement internal API for openvz driver shutdown: Implement internal API for phyp driver shutdown: Implement internal API for uml driver shutdown: Implement internal API for vbox driver shutdown: Implement internal API for vmware driver shutdown: Implement internal API for xen driver shutdown: Implement internal API for xenapi driver include/libvirt/libvirt.h.in | 6 ++++ src/driver.h | 4 +++ src/esx/esx_driver.c | 12 ++++++++- src/libvirt.c | 54 ++++++++++++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 1 + src/libxl/libxl_driver.c | 12 ++++++++- src/openvz/openvz_driver.c | 1 + src/phyp/phyp_driver.c | 12 ++++++++- src/qemu/qemu_driver.c | 12 ++++++++- src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 8 +++++- src/remote_protocol-structs | 5 ++++ src/uml/uml_driver.c | 15 +++++++++++- src/vbox/vbox_tmpl.c | 14 ++++++++++- src/vmware/vmware_driver.c | 1 + src/xen/xen_driver.c | 14 ++++++++-- src/xen/xen_driver.h | 2 +- src/xen/xen_hypervisor.c | 2 +- src/xen/xen_inotify.c | 2 +- src/xen/xend_internal.c | 10 +++++-- src/xen/xend_internal.h | 2 +- src/xen/xm_internal.c | 2 +- src/xen/xs_internal.c | 10 +++++-- src/xen/xs_internal.h | 3 +- src/xenapi/xenapi_driver.c | 25 ++++++++++++++++++- 25 files changed, 206 insertions(+), 24 deletions(-) -- 1.7.5.rc3

This introduces new API virDomainShutdownFlags to allow domain destroying with flags, as the existing API virDomainShutdown misses flags. The set of flags is defined in virDomainShutdownFlagsValues enum, which is currently commented, because it is empty. Calling this API with no flags set (@flags == 0) is equivalent calling virDomainShutdown. --- include/libvirt/libvirt.h.in | 6 ++++ src/driver.h | 4 +++ src/libvirt.c | 54 ++++++++++++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 1 + 4 files changed, 65 insertions(+), 0 deletions(-) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 0b7e35f..8785761 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -920,6 +920,10 @@ virConnectPtr virDomainGetConnect (virDomainPtr domain); * typedef enum { * } virDomainDestroyFlagsValues; */ +/* + * typedef enum{ + * } virDomainShutdownFlagsValues; + */ virDomainPtr virDomainCreateXML (virConnectPtr conn, const char *xmlDesc, unsigned int flags); @@ -933,6 +937,8 @@ virDomainPtr virDomainLookupByUUIDString (virConnectPtr conn, const char *uuid); int virDomainShutdown (virDomainPtr domain); +int virDomainShutdownFlags (virDomainPtr domain, + unsigned int flags); int virDomainReboot (virDomainPtr domain, unsigned int flags); int virDomainDestroy (virDomainPtr domain); diff --git a/src/driver.h b/src/driver.h index 4df5496..e6b057c 100644 --- a/src/driver.h +++ b/src/driver.h @@ -120,6 +120,9 @@ typedef int typedef int (*virDrvDomainShutdown) (virDomainPtr domain); typedef int + (*virDrvDomainShutdownFlags) (virDomainPtr domain, + unsigned int flags); +typedef int (*virDrvDomainReboot) (virDomainPtr domain, unsigned int flags); typedef int @@ -712,6 +715,7 @@ struct _virDriver { virDrvDomainSuspend domainSuspend; virDrvDomainResume domainResume; virDrvDomainShutdown domainShutdown; + virDrvDomainShutdownFlags domainShutdownFlags; virDrvDomainReboot domainReboot; virDrvDomainDestroy domainDestroy; virDrvDomainDestroyFlags domainDestroyFlags; diff --git a/src/libvirt.c b/src/libvirt.c index 7fb1bc1..a826c7b 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -2756,6 +2756,60 @@ error: } /** + * virDomainShutdownFlags: + * @domain: a domain object + * @flags: an OR'ed set of virDomainShutdownFlagsValues + * + * Shutdown a domain, the domain object is still usable there after but + * the domain OS is being stopped. Note that the guest OS may ignore the + * request. + * + * TODO: should we add an option for reboot, knowing it may not be doable + * in the general case ? + * + * Calling this function with no @flags set (equal to zero) + * is equivalent to calling virDomainShutdown. + * + * Returns 0 in case of success and -1 in case of failure. + */ +int +virDomainShutdownFlags(virDomainPtr domain, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain); + + virResetLastError(); + + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { + virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); + virDispatchError(NULL); + return -1; + } + if (domain->conn->flags & VIR_CONNECT_RO) { + virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); + goto error; + } + + conn = domain->conn; + + if (conn->driver->domainShutdownFlags) { + int ret; + ret = conn->driver->domainShutdownFlags(domain, flags); + if (ret < 0) + goto error; + return ret; + } + + virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + +error: + virDispatchError(domain->conn); + return -1; +} + +/** * virDomainReboot: * @domain: a domain object * @flags: extra flags for the reboot operation, not used yet diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 9336df4..a8447d9 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -472,6 +472,7 @@ LIBVIRT_0.9.4 { virDomainSaveFlags; virDomainUndefineFlags; virDomainDestroyFlags; + virDomainShutdownFlags; } LIBVIRT_0.9.3; # .... define new API here using predicted next version number .... -- 1.7.5.rc3

On 07/21/2011 02:53 PM, Michal Privoznik wrote:
This introduces new API virDomainShutdownFlags to allow domain destroying with flags, as the existing API virDomainShutdown misses flags.
The set of flags is defined in virDomainShutdownFlagsValues enum, which is currently commented, because it is empty.
Calling this API with no flags set (@flags == 0) is equivalent calling virDomainShutdown. --- include/libvirt/libvirt.h.in | 6 ++++ src/driver.h | 4 +++ src/libvirt.c | 54 ++++++++++++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 1 + 4 files changed, 65 insertions(+), 0 deletions(-)
/** + * virDomainShutdownFlags: + * @domain: a domain object + * @flags: an OR'ed set of virDomainShutdownFlagsValues + * + * Shutdown a domain, the domain object is still usable there after but + * the domain OS is being stopped. Note that the guest OS may ignore the + * request. + * + * TODO: should we add an option for reboot, knowing it may not be doable + * in the general case ?
Do we really want this TODO to show up in the web page? And this same question could be asked of virDomainDestroyFlags, since it is conceivable to have hardware where the BIOS is set to auto-power-on after a power-loss event; virDomainDestroy corresponds to the power loss, and the auto-restart flag corresponds to the BIOS wakeup event.
+ * + * Calling this function with no @flags set (equal to zero) + * is equivalent to calling virDomainShutdown. + * + * Returns 0 in case of success and -1 in case of failure. + */ +int +virDomainShutdownFlags(virDomainPtr domain, + unsigned int flags)
Is this flexible enough? Since shutdown requires guest cooperation, I wonder if we should instead provide this signature: virDomainShutdownFlags(virDomainPtr domain, unsigned int timeout, unsigned int flags) If @timeout is 0, nothing further is done after requesting the guest shutdown. If @timeout is non-zero, then if that many seconds elapse and the guest is still running, then the hypervisor will forcefully stop the guest as if by virDomainDestroyFlags, using the same set of flags passed to this function. In all cases, this command returns immediately after making the shutdown request; you must register for domain lifecycle events or poll for domain status to see if the domain has actually shut down yet. Or possibly: If @timeout is 0, nothing further is done after requesting the guest shutdown. If @timeout is non-zero, then if that many seconds elapse and the guest is still running, then the hypervisor will forcefully stop the guest as if by virDomainDestroyFlags, using the same set of flags passed to this function except VIR_DOMAIN_SHUTDOWN_BLOCK. In all cases, if @flags includes VIR_DOMAIN_SHUTDOWN_BLOCK, this command blocks until the guest halts or the timeout expires or virDomainShutdownAbort() is called by another thread; without that flag, this call returns immediately after making the shutdown request and you must register for domain lifecycle events or poll for domain status to see if the domain has actually shut down yet. I know I said earlier that it would be nice to provide virDomainShutdownFlags as a parallel to virDestroyFlags, so we aren't locked into a flag-less API, but now that I think about it more, I'm worried that we might still be locking ourselves into something too inflexible. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Thu, Jul 21, 2011 at 03:52:52PM -0600, Eric Blake wrote:
On 07/21/2011 02:53 PM, Michal Privoznik wrote:
This introduces new API virDomainShutdownFlags to allow domain destroying with flags, as the existing API virDomainShutdown misses flags.
The set of flags is defined in virDomainShutdownFlagsValues enum, which is currently commented, because it is empty.
Calling this API with no flags set (@flags == 0) is equivalent calling virDomainShutdown. --- include/libvirt/libvirt.h.in | 6 ++++ src/driver.h | 4 +++ src/libvirt.c | 54 ++++++++++++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 1 + 4 files changed, 65 insertions(+), 0 deletions(-)
/** + * virDomainShutdownFlags: + * @domain: a domain object + * @flags: an OR'ed set of virDomainShutdownFlagsValues + * + * Shutdown a domain, the domain object is still usable there after but + * the domain OS is being stopped. Note that the guest OS may ignore the + * request. + * + * TODO: should we add an option for reboot, knowing it may not be doable + * in the general case ?
Do we really want this TODO to show up in the web page?
Not really...
And this same question could be asked of virDomainDestroyFlags, since it is conceivable to have hardware where the BIOS is set to auto-power-on after a power-loss event; virDomainDestroy corresponds to the power loss, and the auto-restart flag corresponds to the BIOS wakeup event.
I don't think that analogy really works in virt to be honest.
+ * + * Calling this function with no @flags set (equal to zero) + * is equivalent to calling virDomainShutdown. + * + * Returns 0 in case of success and -1 in case of failure. + */ +int +virDomainShutdownFlags(virDomainPtr domain, + unsigned int flags)
Is this flexible enough? Since shutdown requires guest cooperation, I wonder if we should instead provide this signature:
virDomainShutdownFlags(virDomainPtr domain, unsigned int timeout, unsigned int flags)
If @timeout is 0, nothing further is done after requesting the guest shutdown. If @timeout is non-zero, then if that many seconds elapse and the guest is still running, then the hypervisor will forcefully stop the guest as if by virDomainDestroyFlags, using the same set of flags passed to this function. In all cases, this command returns immediately after making the shutdown request; you must register for domain lifecycle events or poll for domain status to see if the domain has actually shut down yet.
Or possibly:
If @timeout is 0, nothing further is done after requesting the guest shutdown. If @timeout is non-zero, then if that many seconds elapse and the guest is still running, then the hypervisor will forcefully stop the guest as if by virDomainDestroyFlags, using the same set of flags passed to this function except VIR_DOMAIN_SHUTDOWN_BLOCK. In all cases, if @flags includes VIR_DOMAIN_SHUTDOWN_BLOCK, this command blocks until the guest halts or the timeout expires or virDomainShutdownAbort() is called by another thread; without that flag, this call returns immediately after making the shutdown request and you must register for domain lifecycle events or poll for domain status to see if the domain has actually shut down yet.
I'm rather loathe to put a timeout parameter in, since that's getting into the realm of policies and this turns into a can of worms. How do you cancel the timeout... Is the timeout preserved if the VM is migrated elsewhere instead ... What if you want todo some ping check of the guest after the timeout occurrs, but before killing...etc.etc. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

--- src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 8 +++++++- src/remote_protocol-structs | 5 +++++ 3 files changed, 13 insertions(+), 1 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 8602f5d..2b68ac8 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -4150,6 +4150,7 @@ static virDriver remote_driver = { .domainSuspend = remoteDomainSuspend, /* 0.3.0 */ .domainResume = remoteDomainResume, /* 0.3.0 */ .domainShutdown = remoteDomainShutdown, /* 0.3.0 */ + .domainShutdownFlags = remoteDomainShutdownFlags, /* 0.9.4 */ .domainReboot = remoteDomainReboot, /* 0.3.0 */ .domainDestroy = remoteDomainDestroy, /* 0.3.0 */ .domainDestroyFlags = remoteDomainDestroyFlags, /* 0.9.4 */ diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index f300204..ded019a 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -667,6 +667,11 @@ struct remote_domain_shutdown_args { remote_nonnull_domain dom; }; +struct remote_domain_shutdown_flags_args { + remote_nonnull_domain dom; + unsigned int flags; +}; + struct remote_domain_reboot_args { remote_nonnull_domain dom; unsigned int flags; @@ -2411,7 +2416,8 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_UNDEFINE_FLAGS = 231, /* autogen autogen */ REMOTE_PROC_DOMAIN_SAVE_FLAGS = 232, /* autogen autogen */ REMOTE_PROC_DOMAIN_RESTORE_FLAGS = 233, /* autogen autogen */ - REMOTE_PROC_DOMAIN_DESTROY_FLAGS = 234 /* autogen autogen */ + REMOTE_PROC_DOMAIN_DESTROY_FLAGS = 234, /* autogen autogen */ + REMOTE_PROC_DOMAIN_SHUTDOWN_FLAGS = 235 /* autogen autogen */ /* * Notice how the entries are grouped in sets of 10 ? diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 94dfb22..556612b 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -383,6 +383,10 @@ struct remote_domain_resume_args { struct remote_domain_shutdown_args { remote_nonnull_domain dom; }; +struct remote_domain_shutdown_flags_args { + remote_nonnull_domain dom; + u_int flags; +}; struct remote_domain_reboot_args { remote_nonnull_domain dom; u_int flags; @@ -1882,4 +1886,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_SAVE_FLAGS = 232, REMOTE_PROC_DOMAIN_RESTORE_FLAGS = 233, REMOTE_PROC_DOMAIN_DESTROY_FLAGS = 234, + REMOTE_PROC_DOMAIN_SHUTDOWN_FLAGS = 235, }; -- 1.7.5.rc3

--- src/qemu/qemu_driver.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6626057..1d4c9ff 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1452,12 +1452,16 @@ cleanup: } -static int qemuDomainShutdown(virDomainPtr dom) { +static int +qemuDomainShutdownFlags(virDomainPtr dom, + unsigned int flags) { struct qemud_driver *driver = dom->conn->privateData; virDomainObjPtr vm; int ret = -1; qemuDomainObjPrivatePtr priv; + virCheckFlags(0, -1); + qemuDriverLock(driver); vm = virDomainFindByUUID(&driver->domains, dom->uuid); qemuDriverUnlock(driver); @@ -1496,6 +1500,11 @@ cleanup: return ret; } +static int +qemuDomainShutdown(virDomainPtr dom) +{ + return qemuDomainShutdownFlags(dom, 0); +} static int qemuDomainReboot(virDomainPtr dom, unsigned int flags) { struct qemud_driver *driver = dom->conn->privateData; @@ -8925,6 +8934,7 @@ static virDriver qemuDriver = { .domainSuspend = qemudDomainSuspend, /* 0.2.0 */ .domainResume = qemudDomainResume, /* 0.2.0 */ .domainShutdown = qemuDomainShutdown, /* 0.2.0 */ + .domainShutdownFlags = qemuDomainShutdownFlags, /* 0.9.4 */ .domainReboot = qemuDomainReboot, /* 0.9.3 */ .domainDestroy = qemuDomainDestroy, /* 0.2.0 */ .domainDestroyFlags = qemuDomainDestroyFlags, /* 0.9.4 */ -- 1.7.5.rc3

--- src/esx/esx_driver.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index c097651..e3073e5 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -1849,7 +1849,8 @@ esxDomainResume(virDomainPtr domain) static int -esxDomainShutdown(virDomainPtr domain) +esxDomainShutdownFlags(virDomainPtr domain, + unsigned int flags) { int result = -1; esxPrivate *priv = domain->conn->privateData; @@ -1857,6 +1858,8 @@ esxDomainShutdown(virDomainPtr domain) esxVI_String *propertyNameList = NULL; esxVI_VirtualMachinePowerState powerState; + virCheckFlags(0, -1); + if (esxVI_EnsureSession(priv->primary) < 0) { return -1; } @@ -1890,6 +1893,12 @@ esxDomainShutdown(virDomainPtr domain) } +static int +esxDomainShutdown(virDomainPtr domain) +{ + return esxDomainShutdownFlags(domain, 0); +} + static int esxDomainReboot(virDomainPtr domain, unsigned int flags) @@ -4741,6 +4750,7 @@ static virDriver esxDriver = { .domainSuspend = esxDomainSuspend, /* 0.7.0 */ .domainResume = esxDomainResume, /* 0.7.0 */ .domainShutdown = esxDomainShutdown, /* 0.7.0 */ + .domainShutdownFlags = esxDomainShutdownFlags, /* 0.9.4 */ .domainReboot = esxDomainReboot, /* 0.7.0 */ .domainDestroy = esxDomainDestroy, /* 0.7.0 */ .domainDestroyFlags = esxDomainDestroyFlags, /* 0.9.4 */ -- 1.7.5.rc3

--- src/libxl/libxl_driver.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 5f52f38..5a7f173 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -1440,13 +1440,16 @@ cleanup: } static int -libxlDomainShutdown(virDomainPtr dom) +libxlDomainShutdownFlags(virDomainPtr dom, + unsigned int flags) { libxlDriverPrivatePtr driver = dom->conn->privateData; virDomainObjPtr vm; int ret = -1; libxlDomainObjPrivatePtr priv; + virCheckFlags(0, -1); + libxlDriverLock(driver); vm = virDomainFindByUUID(&driver->domains, dom->uuid); if (!vm) { @@ -1484,6 +1487,12 @@ cleanup: } static int +libxlDomainShutdown(virDomainPtr dom) +{ + return libxlDomainShutdownFlags(dom, 0); +} + +static int libxlDomainReboot(virDomainPtr dom, unsigned int flags) { libxlDriverPrivatePtr driver = dom->conn->privateData; @@ -3849,6 +3858,7 @@ static virDriver libxlDriver = { .domainSuspend = libxlDomainSuspend, /* 0.9.0 */ .domainResume = libxlDomainResume, /* 0.9.0 */ .domainShutdown = libxlDomainShutdown, /* 0.9.0 */ + .domainShutdownFlags = libxlDomainShutdownFlags, /* 0.9.4 */ .domainReboot = libxlDomainReboot, /* 0.9.0 */ .domainDestroy = libxlDomainDestroy, /* 0.9.0 */ .domainDestroyFlags = libxlDomainDestroyFlags, /* 0.9.4 */ -- 1.7.5.rc3

--- src/openvz/openvz_driver.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 4e7cb03..392dfef 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1629,6 +1629,7 @@ static virDriver openvzDriver = { .domainSuspend = openvzDomainSuspend, /* 0.8.3 */ .domainResume = openvzDomainResume, /* 0.8.3 */ .domainShutdown = openvzDomainShutdown, /* 0.3.1 */ + .domainShutdownFlags = openvzDomainShutdownFlags, /* 0.9.4 */ .domainReboot = openvzDomainReboot, /* 0.3.1 */ .domainDestroy = openvzDomainShutdown, /* 0.3.1 */ .domainDestroyFlags = openvzDomainShutdownFlags, /* 0.9.4 */ -- 1.7.5.rc3

--- src/phyp/phyp_driver.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index ff16aae..44a3819 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -3428,7 +3428,8 @@ phypDomainReboot(virDomainPtr dom, unsigned int flags) } static int -phypDomainShutdown(virDomainPtr dom) +phypDomainShutdownFlags(virDomainPtr dom, + unsigned int flags) { int result = -1; ConnectionData *connection_data = dom->conn->networkPrivateData; @@ -3441,6 +3442,8 @@ phypDomainShutdown(virDomainPtr dom) char *ret = NULL; virBuffer buf = VIR_BUFFER_INITIALIZER; + virCheckFlags(0, -1); + virBufferAddLit(&buf, "chsysstate"); if (system_type == HMC) virBufferAsprintf(&buf, " -m %s", managed_system); @@ -3459,6 +3462,12 @@ cleanup: } static int +phypDomainShutdown(virDomainPtr dom) +{ + return phypDomainShutdownFlags(dom, 0); +} + +static int phypDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info) { phyp_driverPtr phyp_driver = dom->conn->privateData; @@ -3770,6 +3779,7 @@ static virDriver phypDriver = { .domainLookupByName = phypDomainLookupByName, /* 0.7.0 */ .domainResume = phypDomainResume, /* 0.7.0 */ .domainShutdown = phypDomainShutdown, /* 0.7.0 */ + .domainShutdownFlags = phypDomainShutdownFlags, /* 0.9.4 */ .domainReboot = phypDomainReboot, /* 0.9.1 */ .domainDestroy = phypDomainDestroy, /* 0.7.3 */ .domainDestroyFlags = phypDomainDestroyFlags, /* 0.9.4 */ -- 1.7.5.rc3

--- src/uml/uml_driver.c | 15 ++++++++++++++- 1 files changed, 14 insertions(+), 1 deletions(-) diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 6d04120..70ef4b0 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -1385,12 +1385,17 @@ cleanup: } -static int umlDomainShutdown(virDomainPtr dom) { +static int +umlDomainShutdownFlags(virDomainPtr dom, + unsigned int flags) +{ struct uml_driver *driver = dom->conn->privateData; virDomainObjPtr vm; char *info = NULL; int ret = -1; + virCheckFlags(0, -1); + umlDriverLock(driver); vm = virDomainFindByID(&driver->domains, dom->id); umlDriverUnlock(driver); @@ -1418,6 +1423,13 @@ cleanup: static int +umlDomainShutdown(virDomainPtr dom) +{ + return umlDomainShutdownFlags(dom, 0); +} + + +static int umlDomainDestroyFlags(virDomainPtr dom, unsigned int flags) { @@ -2433,6 +2445,7 @@ static virDriver umlDriver = { .domainLookupByUUID = umlDomainLookupByUUID, /* 0.5.0 */ .domainLookupByName = umlDomainLookupByName, /* 0.5.0 */ .domainShutdown = umlDomainShutdown, /* 0.5.0 */ + .domainShutdownFlags = umlDomainShutdownFlags, /* 0.9.4 */ .domainDestroy = umlDomainDestroy, /* 0.5.0 */ .domainDestroyFlags = umlDomainDestroyFlags, /* 0.9.4 */ .domainGetOSType = umlDomainGetOSType, /* 0.5.0 */ -- 1.7.5.rc3

--- src/vbox/vbox_tmpl.c | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index ee0720a..a315a22 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -1590,7 +1590,10 @@ cleanup: return ret; } -static int vboxDomainShutdown(virDomainPtr dom) { +static int +vboxDomainShutdownFlags(virDomainPtr dom, + unsigned int flags) +{ VBOX_OBJECT_CHECK(dom->conn, int, -1); IMachine *machine = NULL; vboxIID iid = VBOX_IID_INITIALIZER; @@ -1599,6 +1602,8 @@ static int vboxDomainShutdown(virDomainPtr dom) { PRBool isAccessible = PR_FALSE; nsresult rc; + virCheckFlags(0, -1); + vboxIIDFromUUID(&iid, dom->uuid); rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine); if (NS_FAILED(rc)) { @@ -1640,6 +1645,12 @@ cleanup: return ret; } +static int +vboxDomainShutdown(virDomainPtr dom) +{ + return vboxDomainShutdownFlags(dom, 0); +} + static int vboxDomainReboot(virDomainPtr dom, unsigned int flags) { VBOX_OBJECT_CHECK(dom->conn, int, -1); @@ -8783,6 +8794,7 @@ virDriver NAME(Driver) = { .domainSuspend = vboxDomainSuspend, /* 0.6.3 */ .domainResume = vboxDomainResume, /* 0.6.3 */ .domainShutdown = vboxDomainShutdown, /* 0.6.3 */ + .domainShutdownFlags = vboxDomainShutdownFlags, /* 0.9.4 */ .domainReboot = vboxDomainReboot, /* 0.6.3 */ .domainDestroy = vboxDomainDestroy, /* 0.6.3 */ .domainDestroyFlags = vboxDomainDestroyFlags, /* 0.9.4 */ -- 1.7.5.rc3

--- src/vmware/vmware_driver.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 5c63239..c2a4494 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -975,6 +975,7 @@ static virDriver vmwareDriver = { .domainSuspend = vmwareDomainSuspend, /* 0.8.7 */ .domainResume = vmwareDomainResume, /* 0.8.7 */ .domainShutdown = vmwareDomainShutdown, /* 0.8.7 */ + .domainShutdownFlags = vmwareDomainShutdownFlags, /* 0.9.4 */ .domainReboot = vmwareDomainReboot, /* 0.8.7 */ .domainDestroy = vmwareDomainShutdown, /* 0.8.7 */ .domainDestroyFlags = vmwareDomainShutdownFlags, /* 0.9.4 */ -- 1.7.5.rc3

--- src/xen/xen_driver.c | 14 +++++++++++--- src/xen/xen_driver.h | 2 +- src/xen/xen_hypervisor.c | 2 +- src/xen/xen_inotify.c | 2 +- src/xen/xend_internal.c | 10 +++++++--- src/xen/xend_internal.h | 2 +- src/xen/xm_internal.c | 2 +- src/xen/xs_internal.c | 10 +++++++--- src/xen/xs_internal.h | 3 ++- 9 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index e256c33..758d00a 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -872,21 +872,28 @@ xenUnifiedDomainResume (virDomainPtr dom) } static int -xenUnifiedDomainShutdown (virDomainPtr dom) +xenUnifiedDomainShutdownFlags (virDomainPtr dom, + unsigned int flags) { GET_PRIVATE(dom->conn); int i; for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) if (priv->opened[i] && - drivers[i]->domainShutdown && - drivers[i]->domainShutdown (dom) == 0) + drivers[i]->domainShutdownFlags && + drivers[i]->domainShutdownFlags (dom, flags) == 0) return 0; return -1; } static int +xenUnifiedDomainShutdown (virDomainPtr dom) +{ + return xenUnifiedDomainShutdownFlags(dom, 0); +} + +static int xenUnifiedDomainReboot (virDomainPtr dom, unsigned int flags) { GET_PRIVATE(dom->conn); @@ -2213,6 +2220,7 @@ static virDriver xenUnifiedDriver = { .domainSuspend = xenUnifiedDomainSuspend, /* 0.0.3 */ .domainResume = xenUnifiedDomainResume, /* 0.0.3 */ .domainShutdown = xenUnifiedDomainShutdown, /* 0.0.3 */ + .domainShutdownFlags = xenUnifiedDomainShutdownFlags, /* 0.9.4 */ .domainReboot = xenUnifiedDomainReboot, /* 0.1.0 */ .domainDestroy = xenUnifiedDomainDestroy, /* 0.0.3 */ .domainDestroyFlags = xenUnifiedDomainDestroyFlags, /* 0.9.4 */ diff --git a/src/xen/xen_driver.h b/src/xen/xen_driver.h index 039aea3..eed21c7 100644 --- a/src/xen/xen_driver.h +++ b/src/xen/xen_driver.h @@ -92,7 +92,7 @@ struct xenUnifiedDriver { virDrvDomainCreateXML domainCreateXML; virDrvDomainSuspend domainSuspend; virDrvDomainResume domainResume; - virDrvDomainShutdown domainShutdown; + virDrvDomainShutdownFlags domainShutdownFlags; virDrvDomainReboot domainReboot; virDrvDomainDestroyFlags domainDestroyFlags; virDrvDomainGetOSType domainGetOSType; diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c index 0309d8a..4cf8ada 100644 --- a/src/xen/xen_hypervisor.c +++ b/src/xen/xen_hypervisor.c @@ -813,7 +813,7 @@ struct xenUnifiedDriver xenHypervisorDriver = { NULL, /* domainCreateXML */ xenHypervisorPauseDomain, /* domainSuspend */ xenHypervisorResumeDomain, /* domainResume */ - NULL, /* domainShutdown */ + NULL, /* domainShutdownFlags */ NULL, /* domainReboot */ xenHypervisorDestroyDomainFlags, /* domainDestroyFlags */ xenHypervisorDomainGetOSType, /* domainGetOSType */ diff --git a/src/xen/xen_inotify.c b/src/xen/xen_inotify.c index 1496330..1ae8a9b 100644 --- a/src/xen/xen_inotify.c +++ b/src/xen/xen_inotify.c @@ -60,7 +60,7 @@ struct xenUnifiedDriver xenInotifyDriver = { NULL, /* domainCreateLinux */ NULL, /* domainSuspend */ NULL, /* domainResume */ - NULL, /* domainShutdown */ + NULL, /* domainShutdownFlags */ NULL, /* domainReboot */ NULL, /* domainDestroyFlags */ NULL, /* domainGetOSType */ diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index cec2e01..71f5cd5 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -1452,8 +1452,9 @@ xenDaemonDomainResume(virDomainPtr domain) } /** - * xenDaemonDomainShutdown: + * xenDaemonDomainShutdownFlags: * @domain: pointer to the Domain block + * @flags: an OR'ed set of virDomainShutdownFlagsValues * * Shutdown the domain, the OS is requested to properly shutdown * and the domain may ignore it. It will return immediately @@ -1462,8 +1463,11 @@ xenDaemonDomainResume(virDomainPtr domain) * Returns 0 in case of success, -1 (with errno) in case of error. */ int -xenDaemonDomainShutdown(virDomainPtr domain) +xenDaemonDomainShutdownFlags(virDomainPtr domain, + unsigned int flags) { + virCheckFlags(0, -1); + if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) { virXendError(VIR_ERR_INVALID_ARG, __FUNCTION__); return(-1); @@ -3945,7 +3949,7 @@ struct xenUnifiedDriver xenDaemonDriver = { xenDaemonCreateXML, /* domainCreateXML */ xenDaemonDomainSuspend, /* domainSuspend */ xenDaemonDomainResume, /* domainResume */ - xenDaemonDomainShutdown, /* domainShutdown */ + xenDaemonDomainShutdownFlags, /* domainShutdownFlags */ xenDaemonDomainReboot, /* domainReboot */ xenDaemonDomainDestroyFlags, /* domainDestroyFlags */ xenDaemonDomainGetOSType, /* domainGetOSType */ diff --git a/src/xen/xend_internal.h b/src/xen/xend_internal.h index a5dd359..af623a3 100644 --- a/src/xen/xend_internal.h +++ b/src/xen/xend_internal.h @@ -103,7 +103,7 @@ int xenDaemonNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info); int xenDaemonNodeGetTopology(virConnectPtr conn, virCapsPtr caps); int xenDaemonDomainSuspend(virDomainPtr domain); int xenDaemonDomainResume(virDomainPtr domain); -int xenDaemonDomainShutdown(virDomainPtr domain); +int xenDaemonDomainShutdownFlags(virDomainPtr domain, unsigned int flags); int xenDaemonDomainReboot(virDomainPtr domain, unsigned int flags); int xenDaemonDomainDestroyFlags(virDomainPtr domain, unsigned int flags); int xenDaemonDomainSave(virDomainPtr domain, const char *filename); diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c index 185303b..f6e2478 100644 --- a/src/xen/xm_internal.c +++ b/src/xen/xm_internal.c @@ -92,7 +92,7 @@ struct xenUnifiedDriver xenXMDriver = { NULL, /* domainCreateXML */ NULL, /* domainSuspend */ NULL, /* domainResume */ - NULL, /* domainShutdown */ + NULL, /* domainShutdownFlags */ NULL, /* domainReboot */ NULL, /* domainDestroyFlags */ NULL, /* domainGetOSType */ diff --git a/src/xen/xs_internal.c b/src/xen/xs_internal.c index c1b00e5..8816af1 100644 --- a/src/xen/xs_internal.c +++ b/src/xen/xs_internal.c @@ -53,7 +53,7 @@ struct xenUnifiedDriver xenStoreDriver = { NULL, /* domainCreateXML */ NULL, /* domainSuspend */ NULL, /* domainResume */ - xenStoreDomainShutdown, /* domainShutdown */ + xenStoreDomainShutdownFlags, /* domainShutdownFlags */ xenStoreDomainReboot, /* domainReboot */ NULL, /* domainDestroyFlags */ xenStoreDomainGetOSType, /* domainGetOSType */ @@ -738,8 +738,9 @@ done: } /** - * xenStoreDomainShutdown: + * xenStoreDomainShutdownFlags: * @domain: pointer to the Domain block + * @flags: an OR'ed set of virDomainShutdownFlagsValues * * Shutdown the domain, the OS is requested to properly shutdown * and the domain may ignore it. It will return immediately @@ -748,11 +749,14 @@ done: * Returns 0 in case of success, -1 in case of error. */ int -xenStoreDomainShutdown(virDomainPtr domain) +xenStoreDomainShutdownFlags(virDomainPtr domain, + unsigned int flags) { int ret; xenUnifiedPrivatePtr priv; + virCheckFlags(0, -1); + if ((domain == NULL) || (domain->conn == NULL)) { virXenStoreError(VIR_ERR_INVALID_ARG, __FUNCTION__); return(-1); diff --git a/src/xen/xs_internal.h b/src/xen/xs_internal.h index 0278799..5d823d8 100644 --- a/src/xen/xs_internal.h +++ b/src/xen/xs_internal.h @@ -37,7 +37,8 @@ unsigned long xenStoreGetMaxMemory (virDomainPtr domain); int xenStoreDomainSetMemory (virDomainPtr domain, unsigned long memory); unsigned long xenStoreDomainGetMaxMemory(virDomainPtr domain); -int xenStoreDomainShutdown (virDomainPtr domain); +int xenStoreDomainShutdownFlags (virDomainPtr domain, + unsigned int flags); int xenStoreDomainReboot (virDomainPtr domain, unsigned int flags); -- 1.7.5.rc3

On 07/21/2011 02:54 PM, Michal Privoznik wrote:
--- src/xen/xen_driver.c | 14 +++++++++++--- src/xen/xen_driver.h | 2 +- src/xen/xen_hypervisor.c | 2 +- src/xen/xen_inotify.c | 2 +- src/xen/xend_internal.c | 10 +++++++--- src/xen/xend_internal.h | 2 +- src/xen/xm_internal.c | 2 +- src/xen/xs_internal.c | 10 +++++++--- src/xen/xs_internal.h | 3 ++- 9 files changed, 32 insertions(+), 15 deletions(-)
Too complex. This patch would be better off touching _just_ xen_driver.c, or at least waiting until after my xen cleanups have been applied: https://www.redhat.com/archives/libvir-list/2011-July/msg01577.html https://www.redhat.com/archives/libvir-list/2011-July/msg01591.html -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

--- src/xenapi/xenapi_driver.c | 25 +++++++++++++++++++++++-- 1 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index dae7e26..3f3a630 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -767,14 +767,22 @@ xenapiDomainResume (virDomainPtr dom) } /* - * xenapiDomainShutdown + * xenapiDomainShutdownFlags: + * @dom: domain object + * @flags: an OR'ed set of virDomainShutdownFlagsValues + * + * Calling this function with no @flags set (equal to zero) + * is equivalent to calling xenapiDomainShutdown. * * shutsdown a VM * Returns 0 on success or -1 in case of error */ static int -xenapiDomainShutdown (virDomainPtr dom) +xenapiDomainShutdownFlags(virDomainPtr dom, + unsigned int flags) { + virCheckFlags(0, -1); + /* vm.clean_shutdown */ xen_vm vm; xen_vm_set *vms; @@ -802,6 +810,18 @@ xenapiDomainShutdown (virDomainPtr dom) } /* + * xenapiDomainShutdown: + * @dom: domain object + * + * See xenapiDomainShutdownFlags + */ +static int +xenapiDomainShutdown(virDomainPtr dom) +{ + return xenapiDomainShutdownFlags(dom, 0); +} + +/* * xenapiDomainReboot * * Reboots a VM @@ -1901,6 +1921,7 @@ static virDriver xenapiDriver = { .domainSuspend = xenapiDomainSuspend, /* 0.8.0 */ .domainResume = xenapiDomainResume, /* 0.8.0 */ .domainShutdown = xenapiDomainShutdown, /* 0.8.0 */ + .domainShutdownFlags = xenapiDomainShutdownFlags, /* 0.9.4 */ .domainReboot = xenapiDomainReboot, /* 0.8.0 */ .domainDestroy = xenapiDomainDestroy, /* 0.8.0 */ .domainDestroyFlags = xenapiDomainDestroyFlags, /* 0.9.4 */ -- 1.7.5.rc3

On 07/21/2011 02:54 PM, Michal Privoznik wrote:
--- src/xenapi/xenapi_driver.c | 25 +++++++++++++++++++++++-- 1 files changed, 23 insertions(+), 2 deletions(-)
*/ static int -xenapiDomainShutdown (virDomainPtr dom) +xenapiDomainShutdownFlags(virDomainPtr dom, + unsigned int flags) { + virCheckFlags(0, -1); + /* vm.clean_shutdown */ xen_vm vm;
Typically, we list the virCheckFlags() after all the other declarations, but before the first statement. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Michal Privoznik