From dd0ef7b0c802118e6dac031e1d594160d20f8163 Mon Sep 17 00:00:00 2001 From: Xu Yandong Date: Mon, 11 May 2020 17:01:15 +0800 Subject: [PATCH] bugfix: fix virsh dump/migrate and virDaemon return code error Signed-off-by: Xu Yandong --- ...emon-fix-waiting-for-child-processes.patch | 53 +++++++++++ ...Fix-return-code-for-dump-and-migrate.patch | 88 +++++++++++++++++++ libvirt-virsh-Fix-return-code-for-dump.patch | 44 ++++++++++ libvirt.spec | 9 +- 4 files changed, 192 insertions(+), 2 deletions(-) create mode 100644 libvirt-util-virdaemon-fix-waiting-for-child-processes.patch create mode 100644 libvirt-virsh-Fix-return-code-for-dump-and-migrate.patch create mode 100644 libvirt-virsh-Fix-return-code-for-dump.patch diff --git a/libvirt-util-virdaemon-fix-waiting-for-child-processes.patch b/libvirt-util-virdaemon-fix-waiting-for-child-processes.patch new file mode 100644 index 0000000..b397b89 --- /dev/null +++ b/libvirt-util-virdaemon-fix-waiting-for-child-processes.patch @@ -0,0 +1,53 @@ +From 66ee42dc1a3a1445fed97c000f949ae0455bf948 Mon Sep 17 00:00:00 2001 +From: Rafael Fonseca +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 +Reported-by: Marcin Krol +Reviewed-by: Ján Tomko +Signed-off-by: Ján Tomko +(cherry-picked from commit a87e4788d2ee3d74cef5679d2961689d4e4a96a3) +Signed-off-by: Xu Yandong +--- + 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 + diff --git a/libvirt-virsh-Fix-return-code-for-dump-and-migrate.patch b/libvirt-virsh-Fix-return-code-for-dump-and-migrate.patch new file mode 100644 index 0000000..96400a9 --- /dev/null +++ b/libvirt-virsh-Fix-return-code-for-dump-and-migrate.patch @@ -0,0 +1,88 @@ +From 0009ad3497c09ecf45412511edf765f695a506dd Mon Sep 17 00:00:00 2001 +From: Andrea Bolognani +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 +Signed-off-by: Andrea Bolognani +Reviewed-by: Daniel P. Berrangé +(cherry-picked from commit 3169e06a2080bf3335d947de4d4f6235bf2f440d) +Signed-off-by: Xu Yandong +--- + 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 + diff --git a/libvirt-virsh-Fix-return-code-for-dump.patch b/libvirt-virsh-Fix-return-code-for-dump.patch new file mode 100644 index 0000000..a30711b --- /dev/null +++ b/libvirt-virsh-Fix-return-code-for-dump.patch @@ -0,0 +1,44 @@ +From 3e4b15eb78b5815ad4101644efc37bd2bab6608e Mon Sep 17 00:00:00 2001 +From: Xu Yandong +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 +--- + 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 + diff --git a/libvirt.spec b/libvirt.spec index 8959f74..b8baf17 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -99,7 +99,7 @@ Summary: Library providing a simple virtualization API Name: libvirt Version: 6.2.0 -Release: 3 +Release: 4 License: LGPLv2+ 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 Patch0014: libvirt-tests-add-cpu-compare-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-config-network = %{version}-%{release} @@ -1856,6 +1858,9 @@ exit 0 %changelog +* Mon May 11 2020 Xu Yandong - 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 - 6.2.0-3 - Checkout cpu capabilities support for ARM architecture. - Support Kunpeng-920 CPU.