[libvirt] [PATCH v2] examples: fix 64-bit integer formatting on Windows
by Daniel P. Berrangé
The Windows printf functions don't support %llu/%lld for printing 64-bit
integers. For most of libvirt this doesn't matter as we rely on gnulib
which provides a replacement printf that is sane.
The example code is designed to compile against the normal OS headers,
with no use of gnulib and thus has to use the platform specific printf.
To deal with this we must use the macros PRI* macros from inttypes.h
to get the platform specific format string.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
examples/admin/client_info.c | 7 ++++---
examples/admin/list_clients.c | 3 ++-
examples/domtop/domtop.c | 8 ++++++--
3 files changed, 12 insertions(+), 6 deletions(-)
Changed in v2:
- Now actually commit the int64 casts
diff --git a/examples/admin/client_info.c b/examples/admin/client_info.c
index f3f62a656b..7fc6c72bbd 100644
--- a/examples/admin/client_info.c
+++ b/examples/admin/client_info.c
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <time.h>
#include <string.h>
+#include <inttypes.h>
#include <libvirt/libvirt-admin.h>
static const char *
@@ -66,11 +67,11 @@ exampleGetTypedParamValue(virTypedParameterPtr item)
break;
case VIR_TYPED_PARAM_LLONG:
- ret = asprintf(&str, "%lld", item->value.l);
+ ret = asprintf(&str, "%" PRId64, (int64_t)item->value.l);
break;
case VIR_TYPED_PARAM_ULLONG:
- ret = asprintf(&str, "%llu", item->value.ul);
+ ret = asprintf(&str, "%" PRIu64, (uint64_t)item->value.ul);
break;
case VIR_TYPED_PARAM_DOUBLE:
@@ -143,7 +144,7 @@ int main(int argc, char **argv)
if (!(timestr = exampleGetTimeStr(virAdmClientGetTimestamp(clnt))))
goto cleanup;
- printf("%-15s: %llu\n", "id", virAdmClientGetID(clnt));
+ printf("%-15s: %" PRIu64 "\n", "id", (uint64_t)virAdmClientGetID(clnt));
printf("%-15s: %s\n", "connection_time", timestr);
printf("%-15s: %s\n", "transport",
exampleTransportToString(virAdmClientGetTransport(clnt)));
diff --git a/examples/admin/list_clients.c b/examples/admin/list_clients.c
index 5cf8e4c2a6..2876637d42 100644
--- a/examples/admin/list_clients.c
+++ b/examples/admin/list_clients.c
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
+#include <inttypes.h>
#include <libvirt/libvirt-admin.h>
static const char *
@@ -96,7 +97,7 @@ int main(int argc, char **argv)
exampleGetTimeStr(virAdmClientGetTimestamp(client))))
goto cleanup;
- printf(" %-5llu %-15s %-15s\n", id,
+ printf(" %-5" PRIu64 " %-15s %-15s\n", (uint64_t)id,
exampleTransportToString(transport), timestr);
free(timestr);
}
diff --git a/examples/domtop/domtop.c b/examples/domtop/domtop.c
index 008065c651..e1e7fbff8b 100644
--- a/examples/domtop/domtop.c
+++ b/examples/domtop/domtop.c
@@ -29,6 +29,7 @@
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
+#include <inttypes.h>
static bool debug;
static bool run_top;
@@ -226,8 +227,11 @@ print_cpu_usage(const char *dom_name,
return;
}
- DEBUG("now_params=%llu then_params=%llu now=%llu then=%llu",
- now_params[pos].value.ul, then_params[pos].value.ul, now, then);
+ DEBUG("now_params=%" PRIu64 " then_params=%" PRIu64
+ " now=%" PRIu64 " then=%" PRIu64,
+ (uint64_t)now_params[pos].value.ul,
+ (uint64_t)then_params[pos].value.ul,
+ (uint64_t)now, (uint64_t)then);
/* @now_params and @then_params are in nanoseconds, @now and @then are
* in microseconds. In ideal world, we would translate them both into
--
2.20.1
5 years, 6 months
[libvirt] [PATCH 0/2] qemu: caps: Few more cleanups
by Peter Krempa
These were prompted by the review on the original series. Both
will be pushed as trivial once the release is out.
Peter Krempa (2):
qemu: Remove ATTRIBUTE_UNUSED from 'qemuCaps' of
virQEMUCapsInitQMPMonitorTCG
qemu: Remove cleanup section of virQEMUCapsInitQMPMonitorTCG
src/qemu/qemu_capabilities.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
--
2.20.1
5 years, 6 months
[libvirt] [PATCH 0/5] qemu: hotplug: Media change improvements (blockdev-add saga)
by Peter Krempa
First patch is not entirely relevant in this series.
Peter Krempa (5):
qemu: domain: Use VIR_AUTOFREE in
qemuDomainObjPrivateXMLParseBlockjobs
qemu: hotplug: Remove unused copies of virQEMUDriverConfigPtr
qemu: hotplug: Use VIR_AUTOUNREF for virQEMUDriverConfigPtr
qemu: hotplug: Disallow media change while blockjob is active
qemu: domain: Forbid copy_on_read option also for floppies
src/qemu/qemu_domain.c | 23 +++++++++++++------
src/qemu/qemu_hotplug.c | 51 ++++++++++++++++-------------------------
2 files changed, 36 insertions(+), 38 deletions(-)
--
2.20.1
5 years, 6 months
[libvirt] [PATCH] examples: fix 64-bit integer formatting on Windows
by Daniel P. Berrangé
The Windows printf functions don't support %llu/%lld for printing 64-bit
integers. For most of libvirt this doesn't matter as we rely on gnulib
which provides a replacement printf that is sane.
The example code is designed to compile against the normal OS headers,
with no use of gnulib and thus has to use the platform specific printf.
To deal with this we must use the macros PRI* macros from inttypes.h
to get the platform specific format string.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
examples/admin/client_info.c | 7 ++++---
examples/admin/list_clients.c | 3 ++-
examples/domtop/domtop.c | 4 +++-
3 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/examples/admin/client_info.c b/examples/admin/client_info.c
index f3f62a656b..d60512624d 100644
--- a/examples/admin/client_info.c
+++ b/examples/admin/client_info.c
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <time.h>
#include <string.h>
+#include <inttypes.h>
#include <libvirt/libvirt-admin.h>
static const char *
@@ -66,11 +67,11 @@ exampleGetTypedParamValue(virTypedParameterPtr item)
break;
case VIR_TYPED_PARAM_LLONG:
- ret = asprintf(&str, "%lld", item->value.l);
+ ret = asprintf(&str, "%" PRId64, item->value.l);
break;
case VIR_TYPED_PARAM_ULLONG:
- ret = asprintf(&str, "%llu", item->value.ul);
+ ret = asprintf(&str, "%" PRIu64, item->value.ul);
break;
case VIR_TYPED_PARAM_DOUBLE:
@@ -143,7 +144,7 @@ int main(int argc, char **argv)
if (!(timestr = exampleGetTimeStr(virAdmClientGetTimestamp(clnt))))
goto cleanup;
- printf("%-15s: %llu\n", "id", virAdmClientGetID(clnt));
+ printf("%-15s: %" PRIu64 "\n", "id", virAdmClientGetID(clnt));
printf("%-15s: %s\n", "connection_time", timestr);
printf("%-15s: %s\n", "transport",
exampleTransportToString(virAdmClientGetTransport(clnt)));
diff --git a/examples/admin/list_clients.c b/examples/admin/list_clients.c
index 5cf8e4c2a6..545b9cbd01 100644
--- a/examples/admin/list_clients.c
+++ b/examples/admin/list_clients.c
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
+#include <inttypes.h>
#include <libvirt/libvirt-admin.h>
static const char *
@@ -96,7 +97,7 @@ int main(int argc, char **argv)
exampleGetTimeStr(virAdmClientGetTimestamp(client))))
goto cleanup;
- printf(" %-5llu %-15s %-15s\n", id,
+ printf(" %-5" PRIu64 " %-15s %-15s\n", id,
exampleTransportToString(transport), timestr);
free(timestr);
}
diff --git a/examples/domtop/domtop.c b/examples/domtop/domtop.c
index 008065c651..33d97c74fe 100644
--- a/examples/domtop/domtop.c
+++ b/examples/domtop/domtop.c
@@ -29,6 +29,7 @@
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
+#include <inttypes.h>
static bool debug;
static bool run_top;
@@ -226,7 +227,8 @@ print_cpu_usage(const char *dom_name,
return;
}
- DEBUG("now_params=%llu then_params=%llu now=%llu then=%llu",
+ DEBUG("now_params=%" PRIu64 " then_params=%" PRIu64
+ " now=%" PRIu64 " then=%" PRIu64,
now_params[pos].value.ul, then_params[pos].value.ul, now, then);
/* @now_params and @then_params are in nanoseconds, @now and @then are
--
2.20.1
5 years, 6 months
[libvirt] [PATCH 0/3] introducing QEMU_CAPS_QUERY_CURRENT_MACHINE and QEMU_CAPS_WAKEUP_SUSPEND_SUPPORT
by Daniel Henrique Barboza
Hi,
In this series, I present the Libvirt support for a QEMU API that
will be introduced in QEMU 4.0, called 'query-current-machine'.
More background info about the API and its purpose can be found in
the commit msg of patch 1.
Patch 1 contains the caps declarations (a short patch, perhaps
squashable with patch 2).
Patch 2 enable the QEMU_CAPS_WAKEUP_SUSPEND_SUPPORT cap by querying
'query-current-machine', if the QEMU binary supports it.
Patch 3 uses the caps inside qemuDomainPMSuspendForDuration to avoid
suspending a domain that can't wake up from suspend.
Daniel Henrique Barboza (3):
adding QEMU_CAPS_QUERY_CURRENT_MACHINE and
QEMU_CAPS_WAKEUP_SUSPEND_SUPPORT
setting QEMU_CAPS_WAKEUP_SUSPEND_SUPPORT qemu capability
qemuDomainPMSuspendForDuration: check for
QEMU_CAPS_WAKEUP_SUSPEND_SUPPORT
src/qemu/qemu_capabilities.c | 5 +++++
src/qemu/qemu_capabilities.h | 4 ++++
src/qemu/qemu_driver.c | 24 +++++++++++++++++++++++
src/qemu/qemu_monitor.c | 8 ++++++++
src/qemu/qemu_monitor.h | 3 +++
src/qemu/qemu_monitor_json.c | 35 +++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 4 ++++
src/qemu/qemu_process.c | 38 ++++++++++++++++++++++++++++++++++++
8 files changed, 121 insertions(+)
--
2.20.1
5 years, 6 months
[libvirt] Can jobs suck like qemu-pr-helper does be transfered to libvirtd?
by Zhangbo (Oscar)
Hi all:
qemu-pr-helper exits to help qemu do the high-privileged scsi related jobs. LIBVIRTD is responsible to launch qemu-pr-helper and qemu, and set selinux/DAC labels for them and their socket.
#
#
#
#
# ___________
# ___________|libvirtd |__________
# | |___________| |
# | | |
# | | |
# _________|________ _____|______ ___|____
# | qemu-pr-helper |__| vm1.sock |_____| qemu1 |
# |__________________| |____________| |________|
There may be other jobs quite like qemu-pr-helper, shall we make them as "complex" as the qemu-pr-helper scheme?
Will it be OK to just let qemu send an EVENT to libvirtd, and let libvirtd do the SCSI/other jobs? Will it be OK if we remove qemu-pr-helper and similar processes?
What's the disadvantage if we let libvirtd do there high privileged jobs instead qemu-pr-helper-like processes?
Thanks!
5 years, 6 months
[libvirt] [PATCH] virsh: cmdConsole: make --domain optional
by Ján Tomko
In the absence of a domain parameter, console the user instead.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
tools/virsh-domain.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index afcd0a5f8d..de41f6312d 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -49,6 +49,7 @@
#include "virsh-console.h"
#include "virsh-domain-monitor.h"
#include "virerror.h"
+#include "virrandom.h"
#include "virtime.h"
#include "virtypedparam.h"
#include "virxml.h"
@@ -2972,7 +2973,7 @@ static const vshCmdInfo info_console[] = {
};
static const vshCmdOptDef opts_console[] = {
- VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
+ VIRSH_COMMON_OPT_DOMAIN_OT_STRING_FULL(0, VIR_CONNECT_LIST_DOMAINS_ACTIVE),
{.name = "devname", /* sc_prohibit_devname */
.type = VSH_OT_STRING,
.help = N_("character device name")
@@ -3023,6 +3024,23 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom,
return ret;
}
+static const char *
+constellation_phrases[] = {
+ "Everything is going to be all right.",
+ "Things are going to work out in the end.",
+ "Imagine pleasant nonsense", /* https://www.instagram.com/p/BuRfmkrBigI/ */
+ "Ursa Major",
+ "There, there.",
+};
+
+static void
+cmdConsoleUser(vshControl *ctl)
+{
+ uint32_t die = virRandomInt(ARRAY_CARDINALITY(constellation_phrases));
+
+ vshPrintExtra(ctl, "%s", constellation_phrases[die]);
+}
+
static bool
cmdConsole(vshControl *ctl, const vshCmd *cmd)
{
@@ -3033,6 +3051,11 @@ cmdConsole(vshControl *ctl, const vshCmd *cmd)
unsigned int flags = 0;
const char *name = NULL;
+ if (!vshCommandOptBool(cmd, "domain")) {
+ cmdConsoleUser(ctl);
+ return true;
+ }
+
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
return false;
--
2.20.1
5 years, 6 months
[libvirt] vcpupin reports bogus vcpu affinities
by Allen, John
Sent this out to the list a few days ago, but never saw it appear on the
archives. Resending--hopefully this makes it to the list.
---
For pinned vcpus, vcpupin will report inaccurate affinity values on machines
with high core counts (256 cores in my case). The problem is produced as
follows:
$ virsh vcpupin myguest 0 4
$ virsh vcpupin myguest 0
VCPU CPU Affinity
---------------------------
0 4,192,194,196-197
Running taskset on the qemu threads shows the correct affinity, so this seems
to be a reporting problem. Strangely, the value "192" is significant. If I pin
a cpu greater than 192, the problem no longer appears.
I believe the cause of the problem in my case is that in this case in
src/conf/domain_conf.c:virDomainDefGetVcpuPinInfoHelper:
...
if (vcpu && vcpu->cpumask)
bitmap = vcpu->cpumask;
...
vcpu->cpumask is "shortened" in that it is only long enough to contain the last
set bit in the mask. However, when we go to copy the mask to the buffer that is
returned, we use the masklen passed to the function which is the "full"
masklen with a bit for each cpu. So it seems virBitmapToDataBuf copies some
extra data past the end of the bitmask. Why the "192" value is always set and I
typically see similar bogus bits set is still unknown.
What is the function meant to assume in this case? Is it sane to assume that
the bitmask is the full length of the buffer here and it's the responsibility
of the setter of vcpu->cpumask to provide the length of the bitmap we're
expecting? Or should we assume that we may receive a shortened bitmask here and
expand the bitmask before copying to the buffer?
-John
5 years, 6 months
[libvirt] [PATCH] virerror: Make error reporting prettier
by Michal Privoznik
So far, if something goes wrong we print an error message, e.g.
like this:
virsh # start fedora
error: Failed to start domain fedora
error: internal error: process exited while connecting to monitor: 2019-04-01T08:08:49.753850Z qemu-system-x86_64: -object memory-backend-memfd,id=ram-node0,hugetlb=yes,hugetlbsize=0,size=8589934592,host-nodes=0,policy=bind: Property 'memory-backend-memfd.hugetlbsize' doesn't take value '0'
This is very boring and usually too low level for users to know
what is going on or how to fix the problem. Let's reimplement our
error reporting then. After this patch the previous error turns
into (my favourite):
virsh # start fedora
error: Failed to start domain fedora
error: operation failed: the printer thinks its a router.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/Makefile.am | 4 +++
src/util/Makefile.inc.am | 2 ++
src/util/virerror.c | 76 ++++++++++++++++++++++++++++++++++------
3 files changed, 72 insertions(+), 10 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index a73f43c483..387f57f288 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -734,6 +734,7 @@ libvirt_setuid_rpc_client_la_LDFLAGS = \
$(AM_LDFLAGS) \
$(LIBXML_LIBS) \
$(SECDRIVER_LIBS) \
+ $(CURL_LIBS) \
$(NULL)
libvirt_setuid_rpc_client_la_CFLAGS = \
-DLIBVIRT_SETUID_RPC_CLIENT \
@@ -741,6 +742,7 @@ libvirt_setuid_rpc_client_la_CFLAGS = \
-I$(srcdir)/rpc \
$(AM_CFLAGS) \
$(SECDRIVER_CFLAGS) \
+ $(CURL_CFLAGS) \
$(XDR_CFLAGS) \
$(NULL)
endif WITH_SETUID_RPC_CLIENT
@@ -924,6 +926,7 @@ libvirt_nss_la_CFLAGS = \
-DLIBVIRT_NSS \
$(AM_CFLAGS) \
$(YAJL_CFLAGS) \
+ $(CURL_CFLAGS) \
$(NULL)
libvirt_nss_la_LDFLAGS = \
$(AM_LDFLAGS) \
@@ -931,6 +934,7 @@ libvirt_nss_la_LDFLAGS = \
libvirt_nss_la_LIBADD = \
$(YAJL_LIBS) \
+ $(CURL_LIBS) \
$(NULL)
endif WITH_NSS
diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am
index aa5c6cbe03..6852d0105d 100644
--- a/src/util/Makefile.inc.am
+++ b/src/util/Makefile.inc.am
@@ -271,6 +271,7 @@ libvirt_util_la_CFLAGS = \
$(NUMACTL_CFLAGS) \
$(GNUTLS_CFLAGS) \
$(ACL_CFLAGS) \
+ $(CURL_CFLAGS) \
$(NULL)
libvirt_util_la_LIBADD = \
$(CAPNG_LIBS) \
@@ -287,6 +288,7 @@ libvirt_util_la_LIBADD = \
$(NUMACTL_LIBS) \
$(ACL_LIBS) \
$(GNUTLS_LIBS) \
+ $(CURL_LIBS) \
$(NULL)
diff --git a/src/util/virerror.c b/src/util/virerror.c
index 05e535d859..2687869049 100644
--- a/src/util/virerror.c
+++ b/src/util/virerror.c
@@ -21,6 +21,7 @@
#include <config.h>
#include <stdarg.h>
+#include <curl/curl.h>
#include "virerror.h"
#include "datatypes.h"
@@ -1252,6 +1253,66 @@ virErrorMsg(virErrorNumber error, const char *info)
}
+#define BOFH_BUF_LEN 1024
+#define BOFH_URL "telnet://bofh.jeffballard.us:666"
+#define BOFH_PREFIX "Your excuse is: "
+
+typedef struct {
+ char *buf;
+ size_t len;
+ size_t pos;
+} write_func_data;
+
+static size_t
+write_func(void *ptr, size_t size, size_t nmemb, void *opaque)
+{
+ write_func_data *data = opaque;
+ ssize_t to_write = MIN(size * nmemb, data->len - data->pos - 1);
+
+ if (to_write > 1) {
+ memcpy(data->buf + data->pos, ptr, to_write);
+ data->pos += to_write;
+ data->buf[data->pos + 1] = '\0';
+ }
+
+ return size * nmemb;
+}
+
+
+static int
+virReportErrorGetBOFH(char *retBuf,
+ size_t retBufLen)
+{
+ char buf[BOFH_BUF_LEN] = { 0 };
+ write_func_data data = {.buf = buf, .len = sizeof(buf), .pos = 0 };
+ const char *tmp;
+ CURL *curl;
+ CURLcode result;
+
+ if (!(curl = curl_easy_init()))
+ return -1;
+
+ curl_easy_setopt(curl, CURLOPT_URL, BOFH_URL);
+#ifdef CURLOPT_MUTE
+ curl_easy_setopt(curl, CURLOPT_MUTE, 1);
+#endif
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_func);
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, &data);
+
+ result = curl_easy_perform(curl);
+ curl_easy_cleanup(curl);
+ if (result != CURLE_OK)
+ return -1;
+
+ if (!(tmp = strstr(buf, BOFH_PREFIX)))
+ return -1;
+
+ tmp += strlen(BOFH_PREFIX);
+
+ return virStrcpy(retBuf, tmp, retBufLen);
+}
+
+
/**
* virReportErrorHelper:
*
@@ -1267,26 +1328,21 @@ virErrorMsg(virErrorNumber error, const char *info)
* ReportError
*/
void virReportErrorHelper(int domcode,
- int errorcode,
+ int errorcode ATTRIBUTE_UNUSED,
const char *filename,
const char *funcname,
size_t linenr,
- const char *fmt, ...)
+ const char *fmt ATTRIBUTE_UNUSED,
+ ...)
{
int save_errno = errno;
- va_list args;
char errorMessage[VIR_ERROR_MAX_LENGTH];
const char *virerr;
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(errorMessage, sizeof(errorMessage)-1, fmt, args);
- va_end(args);
- } else {
+ if (virReportErrorGetBOFH(errorMessage, sizeof(errorMessage)) < 0)
errorMessage[0] = '\0';
- }
- virerr = virErrorMsg(errorcode, (errorMessage[0] ? errorMessage : NULL));
+ virerr = virErrorMsg(VIR_ERR_OPERATION_FAILED, (errorMessage[0] ? errorMessage : NULL));
virRaiseErrorFull(filename, funcname, linenr,
domcode, errorcode, VIR_ERR_ERROR,
virerr, errorMessage, NULL,
--
2.19.2
5 years, 6 months
[libvirt] [PATCH v2] qemu: fix domain unlock/unref in qemuMigrationSrcPerform
by Nikolay Shirokovskiy
qemuMigrationSrcPerform callers expect it to call virDomainObjEndAPI
in any case so on error paths we miss the virDomainObjEndAPI call.
To fix this let's make qemuMigrationSrcPerform callers responsible
for the virDomainObjEndAPI call.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
---
diff to v1 [1]:
- move virDomainObjEndAPI call to qemuMigrationSrcPerform callers
[1] https://www.redhat.com/archives/libvir-list/2019-April/msg00032.html
src/qemu/qemu_driver.c | 21 +++++++++------------
src/qemu/qemu_migration.c | 2 --
2 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 62d8d97..37baa5c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12550,7 +12550,7 @@ qemuDomainMigratePerform(virDomainPtr dom,
unsigned long resource)
{
virQEMUDriverPtr driver = dom->conn->privateData;
- virDomainObjPtr vm;
+ virDomainObjPtr vm = NULL;
int ret = -1;
const char *dconnuri = NULL;
qemuMigrationParamsPtr migParams = NULL;
@@ -12571,10 +12571,8 @@ qemuDomainMigratePerform(virDomainPtr dom,
if (!(vm = qemuDomObjFromDomain(dom)))
goto cleanup;
- if (virDomainMigratePerformEnsureACL(dom->conn, vm->def) < 0) {
- virDomainObjEndAPI(&vm);
+ if (virDomainMigratePerformEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
- }
if (flags & VIR_MIGRATE_PEER2PEER)
VIR_STEAL_PTR(dconnuri, uri);
@@ -12592,6 +12590,7 @@ qemuDomainMigratePerform(virDomainPtr dom,
flags, dname, resource, false);
cleanup:
+ virDomainObjEndAPI(&vm);
qemuMigrationParamsFree(migParams);
return ret;
}
@@ -12988,7 +12987,7 @@ qemuDomainMigratePerform3(virDomainPtr dom,
unsigned long resource)
{
virQEMUDriverPtr driver = dom->conn->privateData;
- virDomainObjPtr vm;
+ virDomainObjPtr vm = NULL;
qemuMigrationParamsPtr migParams = NULL;
int ret = -1;
@@ -13001,10 +13000,8 @@ qemuDomainMigratePerform3(virDomainPtr dom,
if (!(vm = qemuDomObjFromDomain(dom)))
goto cleanup;
- if (virDomainMigratePerform3EnsureACL(dom->conn, vm->def) < 0) {
- virDomainObjEndAPI(&vm);
+ if (virDomainMigratePerform3EnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
- }
ret = qemuMigrationSrcPerform(driver, dom->conn, vm, xmlin, NULL,
dconnuri, uri, NULL, NULL, 0, NULL, 0,
@@ -13014,6 +13011,7 @@ qemuDomainMigratePerform3(virDomainPtr dom,
flags, dname, resource, true);
cleanup:
+ virDomainObjEndAPI(&vm);
qemuMigrationParamsFree(migParams);
return ret;
}
@@ -13030,7 +13028,7 @@ qemuDomainMigratePerform3Params(virDomainPtr dom,
unsigned int flags)
{
virQEMUDriverPtr driver = dom->conn->privateData;
- virDomainObjPtr vm;
+ virDomainObjPtr vm = NULL;
const char *dom_xml = NULL;
const char *persist_xml = NULL;
const char *dname = NULL;
@@ -13088,10 +13086,8 @@ qemuDomainMigratePerform3Params(virDomainPtr dom,
if (!(vm = qemuDomObjFromDomain(dom)))
goto cleanup;
- if (virDomainMigratePerform3ParamsEnsureACL(dom->conn, vm->def) < 0) {
- virDomainObjEndAPI(&vm);
+ if (virDomainMigratePerform3ParamsEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
- }
ret = qemuMigrationSrcPerform(driver, dom->conn, vm, dom_xml, persist_xml,
dconnuri, uri, graphicsuri, listenAddress,
@@ -13100,6 +13096,7 @@ qemuDomainMigratePerform3Params(virDomainPtr dom,
cookiein, cookieinlen, cookieout, cookieoutlen,
flags, dname, bandwidth, true);
cleanup:
+ virDomainObjEndAPI(&vm);
qemuMigrationParamsFree(migParams);
VIR_FREE(migrate_disks);
return ret;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 419a729..bb43aff 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -4686,7 +4686,6 @@ qemuMigrationSrcPerformJob(virQEMUDriverPtr driver,
}
cleanup:
- virDomainObjEndAPI(&vm);
virObjectEventStateQueue(driver->domainEventState, event);
virObjectUnref(cfg);
return ret;
@@ -4757,7 +4756,6 @@ qemuMigrationSrcPerformPhase(virQEMUDriverPtr driver,
qemuDomainRemoveInactiveJob(driver, vm);
cleanup:
- virDomainObjEndAPI(&vm);
return ret;
}
--
1.8.3.1
5 years, 6 months