[libvirt] [PATCH] qemu: Error prompt when saving a shutoff domain

* src/qemu/qemu_driver.c --- src/qemu/qemu_driver.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c581cfe..8570e67 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4647,6 +4647,12 @@ static int qemudDomainSave(virDomainPtr dom, const char *path) goto cleanup; } + if (!virDomainObjIsActive(vm)) { + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); + goto cleanup; + } + ret = qemudDomainSaveFlag(driver, dom, vm, path, compressed); cleanup: -- 1.7.4

On Tue, Feb 15, 2011 at 04:26:37PM +0800, Osier Yang wrote:
* src/qemu/qemu_driver.c --- src/qemu/qemu_driver.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c581cfe..8570e67 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4647,6 +4647,12 @@ static int qemudDomainSave(virDomainPtr dom, const char *path) goto cleanup; }
+ if (!virDomainObjIsActive(vm)) { + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); + goto cleanup; + } + ret = qemudDomainSaveFlag(driver, dom, vm, path, compressed);
cleanup:
Seems similar to the previous fix on managed save, ACK But I note that the internal routine qemudDomainSaveFlag() used by both front end does that check too, that sounds redundant. Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

"qemudDomainSaveFlag" goto wrong label "endjob", which will cause error when security manager trying to restore label (regression). As it's more reasonable to check if vm is shutoff immediately, and return right away if it is, remove the checking in "qemudDomainSaveFlag", and add checking in "qemudDomainSave". * src/qemu/qemu_driver.c --- src/qemu/qemu_driver.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 82a2210..5f2fcaa 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4332,12 +4332,6 @@ static int qemudDomainSaveFlag(struct qemud_driver *driver, virDomainPtr dom, if (qemuDomainObjBeginJobWithDriver(driver, vm) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - qemuReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); - goto endjob; - } - priv->jobActive = QEMU_JOB_SAVE; memset(&priv->jobInfo, 0, sizeof(priv->jobInfo)); @@ -4656,6 +4650,12 @@ static int qemudDomainSave(virDomainPtr dom, const char *path) goto cleanup; } + if (!virDomainObjIsActive(vm)) { + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); + goto cleanup; + } + ret = qemudDomainSaveFlag(driver, dom, vm, path, compressed); cleanup: -- 1.7.4

On 02/16/2011 03:06 AM, Osier Yang wrote:
"qemudDomainSaveFlag" goto wrong label "endjob", which will cause error when security manager trying to restore label (regression).
As it's more reasonable to check if vm is shutoff immediately, and return right away if it is, remove the checking in "qemudDomainSaveFlag", and add checking in "qemudDomainSave".
* src/qemu/qemu_driver.c --- src/qemu/qemu_driver.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
ACK. The only other caller of qemudDomainSaveFlag is qemuDomainManagedSave, and it also checks that vm is active before calling the helper. One nit: can you adjust the comment before qemudDomainSaveFlag to document that vm must be active (it already documents that it is a helper to be run while the lock is held). Worth applying before 0.8.8. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

于 2011年02月17日 00:22, Eric Blake 写道:
On 02/16/2011 03:06 AM, Osier Yang wrote:
"qemudDomainSaveFlag" goto wrong label "endjob", which will cause error when security manager trying to restore label (regression).
As it's more reasonable to check if vm is shutoff immediately, and return right away if it is, remove the checking in "qemudDomainSaveFlag", and add checking in "qemudDomainSave".
* src/qemu/qemu_driver.c --- src/qemu/qemu_driver.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
ACK. The only other caller of qemudDomainSaveFlag is qemuDomainManagedSave, and it also checks that vm is active before calling the helper.
One nit: can you adjust the comment before qemudDomainSaveFlag to document that vm must be active (it already documents that it is a helper to be run while the lock is held).
Ok, will push it with the comments updates.
Worth applying before 0.8.8.

于 2011年02月15日 17:52, Daniel Veillard 写道:
On Tue, Feb 15, 2011 at 04:26:37PM +0800, Osier Yang wrote:
* src/qemu/qemu_driver.c --- src/qemu/qemu_driver.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c581cfe..8570e67 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4647,6 +4647,12 @@ static int qemudDomainSave(virDomainPtr dom, const char *path) goto cleanup; }
+ if (!virDomainObjIsActive(vm)) { + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); + goto cleanup; + } + ret = qemudDomainSaveFlag(driver, dom, vm, path, compressed);
cleanup:
Seems similar to the previous fix on managed save, ACK
But I note that the internal routine qemudDomainSaveFlag() used by both front end does that check too, that sounds redundant.
Yes, and actually checking in qemudDomainSaveFlag goto wrong label, (endjob, should be from copy-and-paste), in which security manager trys to restore label, that's why the error happens. Removed the checking in qemudDomainSaveFlag in v2 patch. Thanks for the revewing, Regards Osier
participants (3)
-
Daniel Veillard
-
Eric Blake
-
Osier Yang