[libvirt] [PATCH] Resuming running domain raise error message now

This patch introduce raising XML error when user tries to resume domain (Qemu or LXC) which is already running. Closes bug: https://bugzilla.redhat.com/show_bug.cgi?id=1009008 Sławek Kapłoński (1): Resuming running domain raise error message src/lxc/lxc_driver.c | 8 +++++++- src/qemu/qemu_driver.c | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) -- 2.10.1

When user tries to resume already running domain (Qemu or LXC) there is VIR_ERR_OPERATION_INVALID error raised now with message that domain is already running. Closes-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1009008 --- src/lxc/lxc_driver.c | 8 +++++++- src/qemu/qemu_driver.c | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 466e67f..4a0165a 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -3156,6 +3156,7 @@ static int lxcDomainResume(virDomainPtr dom) virDomainObjPtr vm; virObjectEventPtr event = NULL; int ret = -1; + int state; virLXCDomainObjPrivatePtr priv; virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver); @@ -3176,7 +3177,12 @@ static int lxcDomainResume(virDomainPtr dom) goto endjob; } - if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) { + state = virDomainObjGetState(vm, NULL); + if (state == VIR_DOMAIN_RUNNING) { + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is already running")); + goto endjob; + } else if (state == VIR_DOMAIN_PAUSED) { if (virCgroupSetFreezerState(priv->cgroup, "THAWED") < 0) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("Resume operation failed")); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 93ea5e2..c99186a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1919,6 +1919,10 @@ static int qemuDomainResume(virDomainPtr dom) virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("domain is pmsuspended")); goto endjob; + } else if (state == VIR_DOMAIN_RUNNING) { + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is already running")); + goto endjob; } else if ((state == VIR_DOMAIN_CRASHED && reason == VIR_DOMAIN_CRASHED_PANICKED) || state == VIR_DOMAIN_PAUSED) { -- 2.10.1

Hello, Can someone take a look at this patch? Thx in advance :) -- Best regards / Pozdrawiam Sławek Kapłoński slawek@kaplonski.pl On Sat, 22 Oct 2016, Sławek Kapłoński wrote:
When user tries to resume already running domain (Qemu or LXC) there is VIR_ERR_OPERATION_INVALID error raised now with message that domain is already running.
Closes-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1009008 --- src/lxc/lxc_driver.c | 8 +++++++- src/qemu/qemu_driver.c | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 466e67f..4a0165a 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -3156,6 +3156,7 @@ static int lxcDomainResume(virDomainPtr dom) virDomainObjPtr vm; virObjectEventPtr event = NULL; int ret = -1; + int state; virLXCDomainObjPrivatePtr priv; virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
@@ -3176,7 +3177,12 @@ static int lxcDomainResume(virDomainPtr dom) goto endjob; }
- if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) { + state = virDomainObjGetState(vm, NULL); + if (state == VIR_DOMAIN_RUNNING) { + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is already running")); + goto endjob; + } else if (state == VIR_DOMAIN_PAUSED) { if (virCgroupSetFreezerState(priv->cgroup, "THAWED") < 0) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("Resume operation failed")); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 93ea5e2..c99186a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1919,6 +1919,10 @@ static int qemuDomainResume(virDomainPtr dom) virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("domain is pmsuspended")); goto endjob; + } else if (state == VIR_DOMAIN_RUNNING) { + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is already running")); + goto endjob; } else if ((state == VIR_DOMAIN_CRASHED && reason == VIR_DOMAIN_CRASHED_PANICKED) || state == VIR_DOMAIN_PAUSED) { -- 2.10.1
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On Sat, Oct 22, 2016 at 12:30:01PM +0200, Sławek Kapłoński wrote:
When user tries to resume already running domain (Qemu or LXC) there is VIR_ERR_OPERATION_INVALID error raised now with message that domain is already running.
Closes-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1009008 --- src/lxc/lxc_driver.c | 8 +++++++- src/qemu/qemu_driver.c | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-)
I wanted to split this into two commits, separate it for qemu and lxc, but it's so small that when someone were to use this patch, it will fix both qemu and lxc and most likely not cause any merge conflicts =) Congratulations on your first patch. I'll slightly reword the commit message and push this. Martin

Hello, Thx a lot but strictly speaking it's my second patch to libvirt :) -- Best regards / Pozdrawiam Sławek Kapłoński slawek@kaplonski.pl On Wed, 26 Oct 2016, Martin Kletzander wrote:
On Sat, Oct 22, 2016 at 12:30:01PM +0200, Sławek Kapłoński wrote:
When user tries to resume already running domain (Qemu or LXC) there is VIR_ERR_OPERATION_INVALID error raised now with message that domain is already running.
Closes-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1009008 --- src/lxc/lxc_driver.c | 8 +++++++- src/qemu/qemu_driver.c | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-)
I wanted to split this into two commits, separate it for qemu and lxc, but it's so small that when someone were to use this patch, it will fix both qemu and lxc and most likely not cause any merge conflicts =)
Congratulations on your first patch. I'll slightly reword the commit message and push this.
Martin
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On Wed, Oct 26, 2016 at 05:11:58PM +0200, Sławek Kapłoński wrote:
Hello,
Thx a lot but strictly speaking it's my second patch to libvirt :)
I now see it's a fourth one in the three, I have no idea why git log hadn't showed me any other, maybe I was too fast when dismissing it. Well, anyway, good that it's in ;)
participants (2)
-
Martin Kletzander
-
Sławek Kapłoński