bugfix: fix virsh dump/migrate and virDaemon return code error

Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
This commit is contained in:
Xu Yandong 2020-05-11 17:01:15 +08:00
parent e471c406f3
commit dd0ef7b0c8
4 changed files with 192 additions and 2 deletions

View File

@ -0,0 +1,53 @@
From 66ee42dc1a3a1445fed97c000f949ae0455bf948 Mon Sep 17 00:00:00 2001
From: Rafael Fonseca <r4f4rfs@gmail.com>
Date: Tue, 21 Apr 2020 15:55:46 +0800
Subject: util: virdaemon: fix waiting for child processes
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Unlike `waitpid`, `virProcessWait` only returns -1 (error) or 0
(success), so comparing that to `pid` will always be false and the
parent will report failure with:
error : main:851 : Failed to fork as daemon: No such file or directory
even though the grandchild process is succesfully running. Note that the
errno message is misleading: it was last set when trying to find a
restart state file.
Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Reported-by: Marcin Krol <hawk@tld-linux.org>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
(cherry-picked from commit a87e4788d2ee3d74cef5679d2961689d4e4a96a3)
Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
---
src/util/virdaemon.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/util/virdaemon.c b/src/util/virdaemon.c
index 5d92c7d..99530fd 100644
--- a/src/util/virdaemon.c
+++ b/src/util/virdaemon.c
@@ -97,15 +97,14 @@ virDaemonForkIntoBackground(const char *argv0)
default:
{
/* parent */
- int got, exitstatus = 0;
+ int exitstatus = 0;
int ret;
char status;
VIR_FORCE_CLOSE(statuspipe[1]);
/* We wait to make sure the first child forked successfully */
- if ((got = virProcessWait(pid, &exitstatus, 0)) < 0 ||
- got != pid ||
+ if (virProcessWait(pid, &exitstatus, 0) < 0 ||
exitstatus != 0) {
goto error;
}
--
2.23.0

View File

@ -0,0 +1,88 @@
From 0009ad3497c09ecf45412511edf765f695a506dd Mon Sep 17 00:00:00 2001
From: Andrea Bolognani <abologna@redhat.com>
Date: Tue, 21 Apr 2020 19:06:16 +0200
Subject: virsh: Fix return code for dump and migrate
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
When the job monitoring logic was refactored, these two commands
were not converted properly and the result is that a successful
dump or migration (char '0') would be reported as a failed one
(int 48) instead.
Fixes: dc0771cfa2e78ffecd7c8234538ee548748d7bef
Reported-by: Brian Rak <brak@gameservers.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry-picked from commit 3169e06a2080bf3335d947de4d4f6235bf2f440d)
Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
---
tools/virsh-domain.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 2dc7c38..afe360c 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -5436,7 +5436,6 @@ static const vshCmdOptDef opts_dump[] = {
static void
doDump(void *opaque)
{
- char ret = '1';
virshCtrlData *data = opaque;
vshControl *ctl = data->ctl;
const vshCmd *cmd = data->cmd;
@@ -5508,7 +5507,7 @@ doDump(void *opaque)
}
}
- ret = '0';
+ data->ret = 0;
out:
#ifndef WIN32
pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL);
@@ -5516,7 +5515,6 @@ doDump(void *opaque)
#endif /* !WIN32 */
if (dom)
virshDomainFree(dom);
- data->ret = ret;
g_main_loop_quit(data->eventLoop);
}
@@ -10722,7 +10720,6 @@ static const vshCmdOptDef opts_migrate[] = {
static void
doMigrate(void *opaque)
{
- char ret = '1';
virDomainPtr dom = NULL;
const char *desturi = NULL;
const char *opt = NULL;
@@ -11001,14 +10998,14 @@ doMigrate(void *opaque)
if (flags & VIR_MIGRATE_PEER2PEER || vshCommandOptBool(cmd, "direct")) {
if (virDomainMigrateToURI3(dom, desturi, params, nparams, flags) == 0)
- ret = '0';
+ data->ret = 0;
} else {
/* For traditional live migration, connect to the destination host directly. */
virDomainPtr ddom = NULL;
if ((ddom = virDomainMigrate3(dom, dconn, params, nparams, flags))) {
virshDomainFree(ddom);
- ret = '0';
+ data->ret = 0;
}
}
@@ -11019,7 +11016,6 @@ doMigrate(void *opaque)
#endif /* !WIN32 */
virTypedParamsFree(params, nparams);
virshDomainFree(dom);
- data->ret = ret;
g_main_loop_quit(data->eventLoop);
return;
--
2.23.0

View File

@ -0,0 +1,44 @@
From 3e4b15eb78b5815ad4101644efc37bd2bab6608e Mon Sep 17 00:00:00 2001
From: Xu Yandong <xuyandong2@huawei.com>
Date: Mon, 4 May 2020 16:36:19 +0800
Subject: [PATCH] virsh: Fix return code for dump
After the commit dc0771c, ret variable no longer
represents the status of the return code, use
data->ret replace it.
Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
---
tools/virsh-domain.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index afe360c..0a62308 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -5522,7 +5522,6 @@ static bool
cmdDump(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- bool ret = false;
bool verbose = false;
const char *name = NULL;
const char *to = NULL;
@@ -5556,12 +5555,12 @@ cmdDump(vshControl *ctl, const vshCmd *cmd)
virThreadJoin(&workerThread);
- if (!ret)
+ if (!data.ret)
vshPrintExtra(ctl, _("\nDomain %s dumped to %s\n"), name, to);
cleanup:
virshDomainFree(dom);
- return !ret;
+ return !data.ret;
}
static const vshCmdInfo info_screenshot[] = {
--
2.23.0

View File

@ -99,7 +99,7 @@
Summary: Library providing a simple virtualization API Summary: Library providing a simple virtualization API
Name: libvirt Name: libvirt
Version: 6.2.0 Version: 6.2.0
Release: 3 Release: 4
License: LGPLv2+ License: LGPLv2+
URL: https://libvirt.org/ URL: https://libvirt.org/
@ -123,7 +123,9 @@ Patch0012: libvirt-cpu-arm-implment-cpu-baseline-function.patch
Patch0013: libvirt-cpu-arm-implment-cpu-compare-function.patch Patch0013: libvirt-cpu-arm-implment-cpu-compare-function.patch
Patch0014: libvirt-tests-add-cpu-compare-test-cases-for-arm-CPU.patch Patch0014: libvirt-tests-add-cpu-compare-test-cases-for-arm-CPU.patch
Patch0015: libvirt-tests-add-baseline-test-cases-for-arm-CPU.patch Patch0015: libvirt-tests-add-baseline-test-cases-for-arm-CPU.patch
Patch0016: libvirt-util-virdaemon-fix-waiting-for-child-processes.patch
Patch0017: libvirt-virsh-Fix-return-code-for-dump-and-migrate.patch
Patch0018: libvirt-virsh-Fix-return-code-for-dump.patch
Requires: libvirt-daemon = %{version}-%{release} Requires: libvirt-daemon = %{version}-%{release}
Requires: libvirt-daemon-config-network = %{version}-%{release} Requires: libvirt-daemon-config-network = %{version}-%{release}
@ -1856,6 +1858,9 @@ exit 0
%changelog %changelog
* Mon May 11 2020 Xu Yandong <xuyandong2@huawei.com> - 6.2.0-4
- Fix virdaemon waiting for child processes return code error.
- Fix virsh dump and migrate return code error.
* Mon May 11 2020 Xu Yandong <xuyandong2@huawei.com> - 6.2.0-3 * Mon May 11 2020 Xu Yandong <xuyandong2@huawei.com> - 6.2.0-3
- Checkout cpu capabilities support for ARM architecture. - Checkout cpu capabilities support for ARM architecture.
- Support Kunpeng-920 CPU. - Support Kunpeng-920 CPU.