[libvirt] [PATCH] build: avoid older gcc warning
by Eric Blake
Jim Fehlig reported a compilation error with older gcc 4.3.4:
libvirt.c: In function 'virDomainGetEmulatorPinInfo':
libvirt.c:9111: error: logical '&&' with non-zero constant will always evaluate as true [-Wlogical-op]
It looks like someone programmed via too much copy-and-paste.
* src/libvirt.c (virDomainGetEmulatorPinInfo): Multiplying by 1 is
a no-op, and thus will never overflow.
---
Pushing under the build-breaker rule.
src/libvirt.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index 43591c0..ada9a86 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -9108,11 +9108,6 @@ virDomainGetEmulatorPinInfo(virDomainPtr domain, unsigned char *cpumap,
virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
goto error;
}
- if (INT_MULTIPLY_OVERFLOW(1, maplen)) {
- virLibDomainError(VIR_ERR_OVERFLOW, _("input too large: 1 * %d"),
- maplen);
- goto error;
- }
/* At most one of these two flags should be set. */
if ((flags & VIR_DOMAIN_AFFECT_LIVE) &&
--
1.7.11.4
12 years, 3 months
[libvirt] [PATCH] Don't skip over socket label cleanup
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
If QEMU quits immediately after we opened the monitor it was
possible we would skip the clearing of the SELinux process
socket context
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_process.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 70b72af..ade64b7 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1242,12 +1242,11 @@ qemuConnectMonitor(struct qemud_driver *driver, virDomainObjPtr vm)
virDomainObjLock(vm);
priv->monStart = 0;
- if (mon == NULL)
+ if (mon == NULL) {
virObjectUnref(vm);
-
- if (!virDomainObjIsActive(vm)) {
+ } else if (!virDomainObjIsActive(vm)) {
qemuMonitorClose(mon);
- goto error;
+ mon = NULL;
}
priv->mon = mon;
--
1.7.11.2
12 years, 3 months
[libvirt] [PATCH] Fix potential deadlock when agent is closed
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
If the qemuAgentClose method is called from a place which holds
the domain lock, it is theoretically possible to get a deadlock
in the agent destroy callback. This has not ben observed, but
the equivalent code in the QEMU monitor destroy callback has seen
a deadlock.
Remove the redundant locking while unrefing the object and the
bogus assignment
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_process.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index c8c188a..42da617 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -129,7 +129,8 @@ qemuProcessHandleAgentEOF(qemuAgentPtr agent,
virDomainObjLock(vm);
priv = vm->privateData;
- priv->agent = NULL;
+ if (priv->agent == agent)
+ priv->agent = NULL;
virDomainObjUnlock(vm);
qemuDriverUnlock(driver);
@@ -167,16 +168,9 @@ qemuProcessHandleAgentError(qemuAgentPtr agent ATTRIBUTE_UNUSED,
static void qemuProcessHandleAgentDestroy(qemuAgentPtr agent,
virDomainObjPtr vm)
{
- qemuDomainObjPrivatePtr priv;
-
VIR_DEBUG("Received destroy agent=%p vm=%p", agent, vm);
- virDomainObjLock(vm);
- priv = vm->privateData;
- if (priv->agent == agent)
- priv->agent = NULL;
- if (virObjectUnref(vm))
- virDomainObjUnlock(vm);
+ virObjectUnref(vm);
}
--
1.7.11.2
12 years, 3 months
[libvirt] [PATCH] Use size_t instead of int for virDomainDefPtr struct
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Many parts of virDomainDefPtr were using 'int' variables as
array length counts. Replace all these with size_t and update
various format strings & API signatures to adapt
---
src/conf/domain_conf.c | 28 ++++++++++++++--------------
src/conf/domain_conf.h | 40 ++++++++++++++++++++--------------------
src/lxc/lxc_controller.c | 4 ++--
src/parallels/parallels_driver.c | 2 +-
src/qemu/qemu_hotplug.c | 2 +-
src/vbox/vbox_tmpl.c | 8 ++++----
src/vmx/vmx.c | 2 +-
7 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0514540..33e1e7f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10942,7 +10942,7 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src,
if (src->ndisks != dst->ndisks) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target domain disk count %d does not match source %d"),
+ _("Target domain disk count %zu does not match source %zu"),
dst->ndisks, src->ndisks);
goto cleanup;
}
@@ -10953,7 +10953,7 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src,
if (src->ncontrollers != dst->ncontrollers) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target domain disk controller count %d does not match source %d"),
+ _("Target domain disk controller count %zu does not match source %zu"),
dst->ncontrollers, src->ncontrollers);
goto cleanup;
}
@@ -10964,7 +10964,7 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src,
if (src->nfss != dst->nfss) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target domain filesystem count %d does not match source %d"),
+ _("Target domain filesystem count %zu does not match source %zu"),
dst->nfss, src->nfss);
goto cleanup;
}
@@ -10975,7 +10975,7 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src,
if (src->nnets != dst->nnets) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target domain net card count %d does not match source %d"),
+ _("Target domain net card count %zu does not match source %zu"),
dst->nnets, src->nnets);
goto cleanup;
}
@@ -10986,7 +10986,7 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src,
if (src->ninputs != dst->ninputs) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target domain input device count %d does not match source %d"),
+ _("Target domain input device count %zu does not match source %zu"),
dst->ninputs, src->ninputs);
goto cleanup;
}
@@ -10997,7 +10997,7 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src,
if (src->nsounds != dst->nsounds) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target domain sound card count %d does not match source %d"),
+ _("Target domain sound card count %zu does not match source %zu"),
dst->nsounds, src->nsounds);
goto cleanup;
}
@@ -11008,7 +11008,7 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src,
if (src->nvideos != dst->nvideos) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target domain video card count %d does not match source %d"),
+ _("Target domain video card count %zu does not match source %zu"),
dst->nvideos, src->nvideos);
goto cleanup;
}
@@ -11019,7 +11019,7 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src,
if (src->nhostdevs != dst->nhostdevs) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target domain host device count %d does not match source %d"),
+ _("Target domain host device count %zu does not match source %zu"),
dst->nhostdevs, src->nhostdevs);
goto cleanup;
}
@@ -11030,7 +11030,7 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src,
if (src->nsmartcards != dst->nsmartcards) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target domain smartcard count %d does not match source %d"),
+ _("Target domain smartcard count %zu does not match source %zu"),
dst->nsmartcards, src->nsmartcards);
goto cleanup;
}
@@ -11041,7 +11041,7 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src,
if (src->nserials != dst->nserials) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target domain serial port count %d does not match source %d"),
+ _("Target domain serial port count %zu does not match source %zu"),
dst->nserials, src->nserials);
goto cleanup;
}
@@ -11052,7 +11052,7 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src,
if (src->nparallels != dst->nparallels) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target domain parallel port count %d does not match source %d"),
+ _("Target domain parallel port count %zu does not match source %zu"),
dst->nparallels, src->nparallels);
goto cleanup;
}
@@ -11063,7 +11063,7 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src,
if (src->nchannels != dst->nchannels) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target domain channel count %d does not match source %d"),
+ _("Target domain channel count %zu does not match source %zu"),
dst->nchannels, src->nchannels);
goto cleanup;
}
@@ -11074,7 +11074,7 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src,
if (src->nconsoles != dst->nconsoles) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target domain console count %d does not match source %d"),
+ _("Target domain console count %zu does not match source %zu"),
dst->nconsoles, src->nconsoles);
goto cleanup;
}
@@ -11085,7 +11085,7 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src,
if (src->nhubs != dst->nhubs) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target domain hub device count %d does not match source %d"),
+ _("Target domain hub device count %zu does not match source %zu"),
dst->nhubs, src->nhubs);
goto cleanup;
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 1a61318..14dead3 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -552,7 +552,7 @@ struct _virDomainDiskDef {
char *dst;
int tray_status;
int protocol;
- int nhosts;
+ size_t nhosts;
virDomainDiskHostDefPtr hosts;
struct {
char *username;
@@ -1048,7 +1048,7 @@ struct _virDomainSoundDef {
int model;
virDomainDeviceInfo info;
- int ncodecs;
+ size_t ncodecs;
virDomainSoundCodecDefPtr *codecs;
};
@@ -1443,7 +1443,7 @@ struct _virDomainOSDef {
char *type;
char *arch;
char *machine;
- int nBootDevs;
+ size_t nBootDevs;
int bootDevs[VIR_DOMAIN_BOOT_LAST];
/* enum virDomainBootMenu */
int bootmenu;
@@ -1575,7 +1575,7 @@ struct _virDomainClockDef {
char *timezone;
} data;
- int ntimers;
+ size_t ntimers;
virDomainTimerDefPtr *timers;
};
@@ -1695,55 +1695,55 @@ struct _virDomainDef {
virDomainClockDef clock;
- int ngraphics;
+ size_t ngraphics;
virDomainGraphicsDefPtr *graphics;
- int ndisks;
+ size_t ndisks;
virDomainDiskDefPtr *disks;
- int ncontrollers;
+ size_t ncontrollers;
virDomainControllerDefPtr *controllers;
- int nfss;
+ size_t nfss;
virDomainFSDefPtr *fss;
- int nnets;
+ size_t nnets;
virDomainNetDefPtr *nets;
- int ninputs;
+ size_t ninputs;
virDomainInputDefPtr *inputs;
- int nsounds;
+ size_t nsounds;
virDomainSoundDefPtr *sounds;
- int nvideos;
+ size_t nvideos;
virDomainVideoDefPtr *videos;
- int nhostdevs;
+ size_t nhostdevs;
virDomainHostdevDefPtr *hostdevs;
- int nredirdevs;
+ size_t nredirdevs;
virDomainRedirdevDefPtr *redirdevs;
- int nsmartcards;
+ size_t nsmartcards;
virDomainSmartcardDefPtr *smartcards;
- int nserials;
+ size_t nserials;
virDomainChrDefPtr *serials;
- int nparallels;
+ size_t nparallels;
virDomainChrDefPtr *parallels;
- int nchannels;
+ size_t nchannels;
virDomainChrDefPtr *channels;
- int nconsoles;
+ size_t nconsoles;
virDomainChrDefPtr *consoles;
size_t nleases;
virDomainLeaseDefPtr *leases;
- int nhubs;
+ size_t nhubs;
virDomainHubDefPtr *hubs;
size_t nseclabels;
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index d407e70..68f857a 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -319,7 +319,7 @@ static int virLXCControllerValidateNICs(virLXCControllerPtr ctrl)
{
if (ctrl->def->nnets != ctrl->nveths) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("expecting %d veths, but got %zu"),
+ _("expecting %zu veths, but got %zu"),
ctrl->def->nnets, ctrl->nveths);
return -1;
}
@@ -332,7 +332,7 @@ static int virLXCControllerValidateConsoles(virLXCControllerPtr ctrl)
{
if (ctrl->def->nconsoles != ctrl->nconsoles) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("expecting %d consoles, but got %zu tty file handlers"),
+ _("expecting %zu consoles, but got %zu tty file handlers"),
ctrl->def->nconsoles, ctrl->nconsoles);
return -1;
}
diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index 20ee361..a938199 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -222,7 +222,7 @@ parallelsGetSerialInfo(virDomainChrDefPtr chr,
}
static int
-parallelsAddSerialInfo(virDomainChrDefPtr **serials, int *nserials,
+parallelsAddSerialInfo(virDomainChrDefPtr **serials, size_t *nserials,
const char *key, virJSONValuePtr value)
{
virDomainChrDefPtr chr = NULL;
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index bcf3081..a738b19 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2090,7 +2090,7 @@ int qemuDomainDetachThisHostDevice(struct qemud_driver *driver,
}
if (idx >= vm->def->nhostdevs) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("device not found in hostdevs list (%d entries)"),
+ _("device not found in hostdevs list (%zu entries)"),
vm->def->nhostdevs);
return ret;
}
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 4f2d025..29b776d 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -3786,7 +3786,7 @@ vboxSetBootDeviceOrder(virDomainDefPtr def, vboxGlobalData *data,
VIR_DEBUG("def->os.type %s", def->os.type);
VIR_DEBUG("def->os.arch %s", def->os.arch);
VIR_DEBUG("def->os.machine %s", def->os.machine);
- VIR_DEBUG("def->os.nBootDevs %d", def->os.nBootDevs);
+ VIR_DEBUG("def->os.nBootDevs %zu", def->os.nBootDevs);
VIR_DEBUG("def->os.bootDevs[0] %d", def->os.bootDevs[0]);
VIR_DEBUG("def->os.bootDevs[1] %d", def->os.bootDevs[1]);
VIR_DEBUG("def->os.bootDevs[2] %d", def->os.bootDevs[2]);
@@ -4376,7 +4376,7 @@ vboxAttachNetwork(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
systemProperties = NULL;
}
- VIR_DEBUG("Number of Network Cards to be connected: %d", def->nnets);
+ VIR_DEBUG("Number of Network Cards to be connected: %zu", def->nnets);
VIR_DEBUG("Number of Network Cards available: %d", networkAdapterCount);
for (i = 0; (i < def->nnets) && (i < networkAdapterCount); i++) {
@@ -4538,7 +4538,7 @@ vboxAttachSerial(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
systemProperties = NULL;
}
- VIR_DEBUG("Number of Serial Ports to be connected: %d", def->nserials);
+ VIR_DEBUG("Number of Serial Ports to be connected: %zu", def->nserials);
VIR_DEBUG("Number of Serial Ports available: %d", serialPortCount);
for (i = 0; (i < def->nserials) && (i < serialPortCount); i++) {
ISerialPort *serialPort = NULL;
@@ -4617,7 +4617,7 @@ vboxAttachParallel(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
systemProperties = NULL;
}
- VIR_DEBUG("Number of Parallel Ports to be connected: %d", def->nparallels);
+ VIR_DEBUG("Number of Parallel Ports to be connected: %zu", def->nparallels);
VIR_DEBUG("Number of Parallel Ports available: %d", parallelPortCount);
for (i = 0; (i < def->nparallels) && (i < parallelPortCount); i++) {
IParallelPort *parallelPort = NULL;
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 1ccd931..e051de5 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -3299,7 +3299,7 @@ virVMXFormatConfig(virVMXContext *ctx, virCapsPtr caps, virDomainDefPtr def,
/* def:fss */
if (def->nfss > 0) {
virBufferAddLit(&buffer, "isolation.tools.hgfs.disable = \"false\"\n");
- virBufferAsprintf(&buffer, "sharedFolder.maxNum = \"%d\"\n", def->nfss);
+ virBufferAsprintf(&buffer, "sharedFolder.maxNum = \"%zu\"\n", def->nfss);
}
for (i = 0; i < def->nfss; ++i) {
--
1.7.11.2
12 years, 3 months
[libvirt] [PATCH 1/4] parallels: remove unused member 'os' from parallelsDomObj
by Dmitry Guryanov
Signed-off-by: Dmitry Guryanov <dguryanov(a)parallels.com>
---
src/parallels/parallels_utils.h | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/src/parallels/parallels_utils.h b/src/parallels/parallels_utils.h
index 082ee75..6a27003 100644
--- a/src/parallels/parallels_utils.h
+++ b/src/parallels/parallels_utils.h
@@ -44,7 +44,6 @@ typedef struct _parallelsConn *parallelsConnPtr;
struct parallelsDomObj {
int id;
char *uuid;
- char *os;
};
typedef struct parallelsDomObj *parallelsDomObjPtr;
--
1.7.1
12 years, 3 months
[libvirt] [PATCH] Fix deadlock in handling EOF in LXC monitor
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Depending on the scenario in which LXC containers exit, it is
possible for the EOF callback of the LXC monitor to deadlock
the driver. When the driver calls virLXCMonitorClose, there
is really no need for the EOF callback to be invoked in this
case, since the caller can easily handle events itself.
In changing this, the monitor needs to take a deep copy of
the callback list, not merely a reference.
Also adds debug statements in various places to aid
troubleshooting
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/lxc/lxc_monitor.c | 32 ++++++++++++++++++++++----------
src/lxc/lxc_process.c | 6 +++++-
2 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/src/lxc/lxc_monitor.c b/src/lxc/lxc_monitor.c
index 772c613..3e00751 100644
--- a/src/lxc/lxc_monitor.c
+++ b/src/lxc/lxc_monitor.c
@@ -40,7 +40,7 @@ struct _virLXCMonitor {
virMutex lock;
virDomainObjPtr vm;
- virLXCMonitorCallbacksPtr cb;
+ virLXCMonitorCallbacks cb;
virNetClientPtr client;
virNetClientProgramPtr program;
@@ -83,8 +83,8 @@ virLXCMonitorHandleEventExit(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
virLXCProtocolExitEventMsg *msg = evdata;
VIR_DEBUG("Event exit %d", msg->status);
- if (mon->cb->exitNotify)
- mon->cb->exitNotify(mon, msg->status, mon->vm);
+ if (mon->cb.exitNotify)
+ mon->cb.exitNotify(mon, msg->status, mon->vm);
}
@@ -96,20 +96,25 @@ static void virLXCMonitorEOFNotify(virNetClientPtr client ATTRIBUTE_UNUSED,
virLXCMonitorCallbackEOFNotify eofNotify;
virDomainObjPtr vm;
- VIR_DEBUG("EOF notify");
+ VIR_DEBUG("EOF notify mon=%p", mon);
virLXCMonitorLock(mon);
- eofNotify = mon->cb->eofNotify;
+ eofNotify = mon->cb.eofNotify;
vm = mon->vm;
virLXCMonitorUnlock(mon);
- eofNotify(mon, vm);
+ if (eofNotify) {
+ VIR_DEBUG("EOF callback mon=%p vm=%p", mon, vm);
+ eofNotify(mon, vm);
+ } else {
+ VIR_DEBUG("No EOF callback");
+ }
}
static void virLXCMonitorCloseFreeCallback(void *opaque)
{
virLXCMonitorPtr mon = opaque;
- virObjectUnref(mon);;
+ virObjectUnref(mon);
}
@@ -155,7 +160,7 @@ virLXCMonitorPtr virLXCMonitorNew(virDomainObjPtr vm,
goto error;
mon->vm = vm;
- mon->cb = cb;
+ memcpy(&mon->cb, cb, sizeof(mon->cb));
virObjectRef(mon);
virNetClientSetCloseCallback(mon->client, virLXCMonitorEOFNotify, mon,
@@ -179,8 +184,8 @@ static void virLXCMonitorDispose(void *opaque)
virLXCMonitorPtr mon = opaque;
VIR_DEBUG("mon=%p", mon);
- if (mon->cb && mon->cb->destroy)
- (mon->cb->destroy)(mon, mon->vm);
+ if (mon->cb.destroy)
+ (mon->cb.destroy)(mon, mon->vm);
virMutexDestroy(&mon->lock);
virObjectUnref(mon->program);
}
@@ -188,7 +193,14 @@ static void virLXCMonitorDispose(void *opaque)
void virLXCMonitorClose(virLXCMonitorPtr mon)
{
+ VIR_DEBUG("mon=%p", mon);
if (mon->client) {
+ /* When manually closing the monitor, we don't
+ * want to have callbacks back into us, since
+ * the caller is not re-entrant safe
+ */
+ VIR_DEBUG("Clear EOF callback mon=%p", mon);
+ mon->cb.eofNotify = NULL;
virNetClientClose(mon->client);
virObjectUnref(mon->client);
mon->client = NULL;
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index b9cff85..079bc3a 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -169,6 +169,8 @@ virLXCProcessReboot(virLXCDriverPtr driver,
int ret = -1;
virDomainDefPtr savedDef;
+ VIR_DEBUG("Faking reboot");
+
if (conn) {
virConnectRef(conn);
autodestroy = true;
@@ -555,13 +557,15 @@ cleanup:
extern virLXCDriverPtr lxc_driver;
-static void virLXCProcessMonitorEOFNotify(virLXCMonitorPtr mon ATTRIBUTE_UNUSED,
+static void virLXCProcessMonitorEOFNotify(virLXCMonitorPtr mon,
virDomainObjPtr vm)
{
virLXCDriverPtr driver = lxc_driver;
virDomainEventPtr event = NULL;
virLXCDomainObjPrivatePtr priv;
+ VIR_DEBUG("mon=%p vm=%p", mon, vm);
+
lxcDriverLock(driver);
virDomainObjLock(vm);
lxcDriverUnlock(driver);
--
1.7.11.2
12 years, 3 months
[libvirt] [libvirt-glib PATCHv2 1/3] Implement gvir_config_domain_graphics_vnc_set_socket
by Christophe Fergeau
---
libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c | 10 ++++++++++
libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h | 3 +++
libvirt-gconfig/libvirt-gconfig.sym | 2 ++
3 files changed, 15 insertions(+)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c
index f2fc9d5..c9fc408 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c
@@ -76,6 +76,16 @@ gvir_config_domain_graphics_vnc_new_from_xml(const gchar *xml,
}
+void gvir_config_domain_graphics_vnc_set_socket(GVirConfigDomainGraphicsVnc *graphics,
+ const char *socket)
+{
+ g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_VNC(graphics));
+
+ gvir_config_object_set_attribute(GVIR_CONFIG_OBJECT(graphics),
+ "socket", socket,
+ NULL);
+}
+
void gvir_config_domain_graphics_vnc_set_autoport(GVirConfigDomainGraphicsVnc *graphics,
gboolean autoport)
{
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h
index e3183d7..0d3173c 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h
@@ -62,6 +62,9 @@ GVirConfigDomainGraphicsVnc *gvir_config_domain_graphics_vnc_new(void);
GVirConfigDomainGraphicsVnc *gvir_config_domain_graphics_vnc_new_from_xml(const gchar *xml,
GError **error);
+void gvir_config_domain_graphics_vnc_set_socket(GVirConfigDomainGraphicsVnc *graphics,
+ const char *socket);
+
void gvir_config_domain_graphics_vnc_set_autoport(GVirConfigDomainGraphicsVnc *graphics,
gboolean autoport);
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index f83eabb..c60cc4e 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -464,6 +464,8 @@ LIBVIRT_GCONFIG_0.1.3 {
global:
gvir_config_domain_get_current_memory;
gvir_config_domain_set_current_memory;
+
+ gvir_config_domain_graphics_vnc_set_socket;
} LIBVIRT_GCONFIG_0.1.0;
# .... define new API here using predicted next version number ....
--
1.7.11.4
12 years, 3 months
[libvirt] [PATCH 00/13] parallels: implement operations with hard disks
by Dmitry Guryanov
This patch series adds ability to list existing disk images,
create a new ones and add or remove hard disk devices to the VM.
Dmitry Guryanov (13):
parallels: add info about hard disk devices
parallels: handle disk devices in parallelsDomainDefineXML
parallels: split parallelsStorageOpen function
parallels: remove unused code from storage driver
parallels: create storage pools by VM list
parallels: fix leaks in parallelsFindVolumes
parallels: add info about volumes
parallels: fill volumes capacity parameter
parallels: split parallelsStorageVolumeDelete function
parallels: add function parallelsGetDiskBusName
parallels: add support of disks creation
parallels: apply config after VM creation
parallels: add support of removing disks
src/parallels/parallels_driver.c | 346 +++++++++++++++++++++++++--
src/parallels/parallels_storage.c | 478 +++++++++++++++++++++++++++++++------
src/parallels/parallels_utils.h | 3 +
3 files changed, 731 insertions(+), 96 deletions(-)
12 years, 3 months
[libvirt] [PATCH] Change qemuSetSchedularParameters to use AFFECT_CURRENT
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
When adding variants of parameter setting APIs which accepted
flags, the existing APIs were all adapted internally to pass
VIR_DOMAIN_AFFECT_CURRENT to the new API. The QEMU impl
qemuSetSchedularParameters was an exception, which instead
used VIR_DOMAIN_AFFECT_LIVE. Change this to match other
compatibility scenarios, so that calling
virDomainSetSchedularParameters(dom, params, nparams);
Has the same semantics as
virDomainSetSchedularParametersFlags(dom, params, nparams, 0);
And
virDomainSetSchedularParametersFlags(dom, params, nparams, VIR_DOMAIN_AFFECT_CURRENT);
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7ac53ac..d6ecde8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8007,7 +8007,7 @@ qemuSetSchedulerParameters(virDomainPtr dom,
return qemuSetSchedulerParametersFlags(dom,
params,
nparams,
- VIR_DOMAIN_AFFECT_LIVE);
+ VIR_DOMAIN_AFFECT_CURRENT);
}
static int
--
1.7.11.2
12 years, 3 months
[libvirt] [PATCH v4] qemu: wait for SPICE to migrate
by Michal Privoznik
Recently, there have been some improvements made to qemu so it
supports seamless migration or something very close to it.
However, it requires libvirt interaction. Once qemu is migrated,
the SPICE server needs to send its internal state to the destination.
Once it's done, it fires SPICE_MIGRATE_COMPLETED event and this
fact is advertised in 'query-spice' output as well.
We must not kill qemu until SPICE server finishes the transfer.
---
diff to v3:
-drop wait_for_spice argument in qemuMigrationUpdateJobStatus
-refactor wait_for_spice computation
-s/VIR_ERR_CONFIG_UNSUPPORTED/VIR_ERR_OPERATION_UNSUPPORTED
src/qemu/qemu_capabilities.c | 3 ++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 8 ++++++
src/qemu/qemu_migration.c | 19 ++++++++++++++-
src/qemu/qemu_monitor.c | 24 +++++++++++++++++++
src/qemu/qemu_monitor.h | 2 +
src/qemu/qemu_monitor_json.c | 52 ++++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 3 ++
8 files changed, 111 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 3b08ef8..be86014 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -183,6 +183,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
"reboot-timeout", /* 110 */
"dump-guest-core",
+ "seamless-migration",
);
struct _qemuCaps {
@@ -1149,6 +1150,8 @@ qemuCapsComputeCmdFlags(const char *help,
}
if (strstr(help, "-spice"))
qemuCapsSet(caps, QEMU_CAPS_SPICE);
+ if (strstr(help, "seamless-migration="))
+ qemuCapsSet(caps, QEMU_CAPS_SEAMLESS_MIGRATION);
if (strstr(help, "boot=on"))
qemuCapsSet(caps, QEMU_CAPS_DRIVE_BOOT);
if (strstr(help, "serial=s"))
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 485c297..9e4543a 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -147,6 +147,7 @@ enum qemuCapsFlags {
QEMU_CAPS_SECCOMP_SANDBOX = 109, /* -sandbox */
QEMU_CAPS_REBOOT_TIMEOUT = 110, /* -boot reboot-timeout */
QEMU_CAPS_DUMP_GUEST_CORE = 111, /* dump-guest-core-parameter */
+ QEMU_CAPS_SEAMLESS_MIGRATION = 112, /* seamless-migration for SPICE */
QEMU_CAPS_LAST, /* this must always be the last item */
};
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index e7bb88e..4e14ae3 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6150,6 +6150,14 @@ qemuBuildCommandLine(virConnectPtr conn,
if (def->graphics[0]->data.spice.copypaste == VIR_DOMAIN_GRAPHICS_SPICE_CLIPBOARD_COPYPASTE_NO)
virBufferAddLit(&opt, ",disable-copy-paste");
+ if (qemuCapsGet(caps, QEMU_CAPS_SEAMLESS_MIGRATION)) {
+ /* If qemu supports seamless migration turn it
+ * unconditionally on. If migration destination
+ * doesn't support it, it fallbacks to previous
+ * migration algorithm silently. */
+ virBufferAddLit(&opt, ",seamless-migration=on");
+ }
+
virCommandAddArg(cmd, "-spice");
virCommandAddArgBuffer(cmd, &opt);
if (def->graphics[0]->data.spice.keymap)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 8e85875..db69a0a 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -896,10 +896,19 @@ qemuMigrationUpdateJobStatus(struct qemud_driver *driver,
qemuDomainObjPrivatePtr priv = vm->privateData;
int ret;
int status;
+ bool wait_for_spice = false;
+ bool spice_migrated = false;
unsigned long long memProcessed;
unsigned long long memRemaining;
unsigned long long memTotal;
+ /* If guest uses SPICE and supports seamles_migration we have to hold up
+ * migration finish until SPICE server transfers its data */
+ if (vm->def->ngraphics == 1 &&
+ vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE &&
+ qemuCapsGet(priv->caps, QEMU_CAPS_SEAMLESS_MIGRATION))
+ wait_for_spice = true;
+
ret = qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob);
if (ret < 0) {
/* Guest already exited; nothing further to update. */
@@ -910,6 +919,13 @@ qemuMigrationUpdateJobStatus(struct qemud_driver *driver,
&memProcessed,
&memRemaining,
&memTotal);
+
+ /* If qemu says migrated, check spice */
+ if (wait_for_spice && (ret == 0) &&
+ (status == QEMU_MONITOR_MIGRATION_STATUS_COMPLETED))
+ ret = qemuMonitorGetSpiceMigrationStatus(priv->mon,
+ &spice_migrated);
+
qemuDomainObjExitMonitorWithDriver(driver, vm);
if (ret < 0 || virTimeMillisNow(&priv->job.info.timeElapsed) < 0) {
@@ -939,7 +955,8 @@ qemuMigrationUpdateJobStatus(struct qemud_driver *driver,
break;
case QEMU_MONITOR_MIGRATION_STATUS_COMPLETED:
- priv->job.info.type = VIR_DOMAIN_JOB_COMPLETED;
+ if ((wait_for_spice && spice_migrated) || (!wait_for_spice))
+ priv->job.info.type = VIR_DOMAIN_JOB_COMPLETED;
ret = 0;
break;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index fa3b7b2..201b1f4 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1827,6 +1827,30 @@ int qemuMonitorGetMigrationStatus(qemuMonitorPtr mon,
}
+int qemuMonitorGetSpiceMigrationStatus(qemuMonitorPtr mon,
+ bool *spice_migrated)
+{
+ int ret;
+ VIR_DEBUG("mon=%p", mon);
+
+ if (!mon) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("monitor must not be NULL"));
+ return -1;
+ }
+
+ if (mon->json) {
+ ret = qemuMonitorJSONGetSpiceMigrationStatus(mon, spice_migrated);
+ } else {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("JSON monitor is required"));
+ return -1;
+ }
+
+ return ret;
+}
+
+
int qemuMonitorMigrateToFd(qemuMonitorPtr mon,
unsigned int flags,
int fd)
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 6b4eb6f..3455ab9 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -343,6 +343,8 @@ int qemuMonitorGetMigrationStatus(qemuMonitorPtr mon,
unsigned long long *transferred,
unsigned long long *remaining,
unsigned long long *total);
+int qemuMonitorGetSpiceMigrationStatus(qemuMonitorPtr mon,
+ bool *spice_migrated);
typedef enum {
QEMU_MONITOR_MIGRATE_BACKGROUND = 1 << 0,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index f372199..c55ee2b 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2490,6 +2490,58 @@ int qemuMonitorJSONGetMigrationStatus(qemuMonitorPtr mon,
}
+static int
+qemuMonitorJSONSpiceGetMigrationStatusReply(virJSONValuePtr reply,
+ bool *spice_migrated)
+{
+ virJSONValuePtr ret;
+ const char *migrated_str;
+
+ if (!(ret = virJSONValueObjectGet(reply, "return"))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("query-spice reply was missing return data"));
+ return -1;
+ }
+
+ if (!(migrated_str = virJSONValueObjectGetString(ret, "migrated"))) {
+ /* Deliberately don't report error here as we are
+ * probably dealing with older qemu which doesn't
+ * report this yet. Pretend spice is migrated. */
+ *spice_migrated = true;
+ } else {
+ *spice_migrated = STREQ(migrated_str, "true");
+ }
+
+ return 0;
+}
+
+
+int qemuMonitorJSONGetSpiceMigrationStatus(qemuMonitorPtr mon,
+ bool *spice_migrated)
+{
+ int ret;
+ virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("query-spice",
+ NULL);
+ virJSONValuePtr reply = NULL;
+
+ if (!cmd)
+ return -1;
+
+ ret = qemuMonitorJSONCommand(mon, cmd, &reply);
+
+ if (ret == 0)
+ ret = qemuMonitorJSONCheckError(cmd, reply);
+
+ if (ret == 0)
+ ret = qemuMonitorJSONSpiceGetMigrationStatusReply(reply,
+ spice_migrated);
+
+ virJSONValueFree(cmd);
+ virJSONValueFree(reply);
+ return ret;
+}
+
+
int qemuMonitorJSONMigrate(qemuMonitorPtr mon,
unsigned int flags,
const char *uri)
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index e531eb1..751b81f 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -134,6 +134,9 @@ int qemuMonitorJSONGetMigrationStatus(qemuMonitorPtr mon,
int qemuMonitorJSONMigrate(qemuMonitorPtr mon,
unsigned int flags,
const char *uri);
+int qemuMonitorJSONGetSpiceMigrationStatus(qemuMonitorPtr mon,
+ bool *spice_migrated);
+
int qemuMonitorJSONMigrateCancel(qemuMonitorPtr mon);
--
1.7.8.6
12 years, 3 months