[libvirt] [PATCHv3 0/6] Add new command domiftune
by Hu Tao
This series adds a new command domiftune to get/set parameters of
domain's network interfaces. Supported parameters are bandwidth
settings.
Currently the network interface bandwidth can only be set:
- in domain's xml before the domain is up
- when attaching an interface by attach-interface
With this series, users can change network interface bandwidth
settings using virsh, whether the domain is running or not.
changes:
- fix some typos
- improvements on docs
- use virDomainLiveConfigHelperMethod
- some improvements in qemu_driver
Hu Tao (6):
Add API virDomain{S,G}etInterfaceParameters
virDomain{S,G}etInterfaceParameters: the main entry points
Add virDomain{S,G}etInterfaceparameters support to the remote driver
Add a function virDomainFindNetDef
Add virDomain{S,G}etInterfaceParameters support to qemu driver
Enable the virDomain{S,G}etInterfaceParameters in virsh
daemon/remote.c | 64 ++++++++
include/libvirt/libvirt.h.in | 50 ++++++
python/generator.py | 2 +
src/conf/domain_conf.c | 39 +++++
src/conf/domain_conf.h | 3 +
src/driver.h | 12 ++
src/libvirt.c | 129 ++++++++++++++++
src/libvirt_private.syms | 1 +
src/libvirt_public.syms | 2 +
src/qemu/qemu_driver.c | 337 ++++++++++++++++++++++++++++++++++++++++++
src/remote/remote_driver.c | 52 +++++++
src/remote/remote_protocol.x | 28 ++++-
src/remote_protocol-structs | 24 +++
tools/virsh.c | 198 +++++++++++++++++++++++++
tools/virsh.pod | 21 +++
15 files changed, 961 insertions(+), 1 deletions(-)
--
1.7.4.4
12 years, 11 months
[libvirt] [PATCH] virsh: move version command to virsh group
by Lai Jiangshan
Trivial patch, move version command to virsh commands group.
It has no any related with any domain.
It may connect to the daemon, so the flag is 0 but not VSH_CMD_FLAG_NOCONNECT.
---
diff --git a/tools/virsh.c b/tools/virsh.c
index 02f2e0d..0166bc6 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -15641,7 +15641,6 @@ static const vshCmdDef domManagementCmds[] = {
{"vcpucount", cmdVcpucount, opts_vcpucount, info_vcpucount, 0},
{"vcpuinfo", cmdVcpuinfo, opts_vcpuinfo, info_vcpuinfo, 0},
{"vcpupin", cmdVcpuPin, opts_vcpupin, info_vcpupin, 0},
- {"version", cmdVersion, opts_version, info_version, 0},
{"vncdisplay", cmdVNCDisplay, opts_vncdisplay, info_vncdisplay, 0},
{NULL, NULL, NULL, NULL, 0}
};
@@ -15810,6 +15809,7 @@ static const vshCmdDef secretCmds[] = {
};
static const vshCmdDef virshCmds[] = {
+ {"version", cmdVersion, opts_version, info_version, 0},
{"cd", cmdCd, opts_cd, info_cd, VSH_CMD_FLAG_NOCONNECT},
{"echo", cmdEcho, opts_echo, info_echo, VSH_CMD_FLAG_NOCONNECT},
{"exit", cmdQuit, NULL, info_quit, VSH_CMD_FLAG_NOCONNECT},
12 years, 11 months
[libvirt] [PATCH] daemon: fix fd leak on libvirtd
by ajia@redhat.com
From: Alex Jia <ajia(a)redhat.com>
The codes hasn't close a pipe decriptor statuspipe[0] before exiting,
moreover, should also close all of opening fds on error path to
avoid fd leaks.
In addition, I think other fds leak doesen't belong to libvirtd,
so this patch hasn't fixed them.
Detected by valgrind. Leaks introduced in commit 4296cea.
* daemon/libvirtd.c: fix fd leak on libvirt daemon.
* How to reproduce?
% service libvirtd stop
% valgrind -v --track-fds=yes /usr/sbin/libvirtd --daemon
* Actual valgrind result:
==16804== FILE DESCRIPTORS: 7 open at exit.
==16804== Open file descriptor 7:
==16804== at 0x321FAD8B87: pipe (in /lib64/libc-2.12.so)
==16804== by 0x41F34D: daemonForkIntoBackground (libvirtd.c:186)
==16804== by 0x4207A0: main (libvirtd.c:1420)
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
daemon/libvirtd.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index d7a03d7..b05f126 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -184,7 +184,7 @@ static int daemonForkIntoBackground(const char *argv0)
{
int statuspipe[2];
if (pipe(statuspipe) < 0)
- return -1;
+ goto error;
int pid = fork();
switch (pid) {
@@ -219,7 +219,7 @@ static int daemonForkIntoBackground(const char *argv0)
case 0:
return statuspipe[1];
case -1:
- return -1;
+ goto error;
default:
_exit(0);
}
@@ -232,7 +232,7 @@ static int daemonForkIntoBackground(const char *argv0)
}
case -1:
- return -1;
+ goto error;
default:
{
@@ -243,7 +243,7 @@ static int daemonForkIntoBackground(const char *argv0)
/* We wait to make sure the first child forked successfully */
if (virPidWait(pid, NULL) < 0)
- return -1;
+ goto error;
/* Now block until the second child initializes successfully */
again:
@@ -257,9 +257,15 @@ static int daemonForkIntoBackground(const char *argv0)
"--daemon for more info.\n"), argv0,
virDaemonErrTypeToString(status));
}
+ VIR_FORCE_CLOSE(statuspipe[0]);
_exit(ret == 1 && status == 0 ? 0 : 1);
}
}
+
+error:
+ VIR_FORCE_CLOSE(statuspipe[0]);
+ VIR_FORCE_CLOSE(statuspipe[1]);
+ return -1;
}
--
1.7.1
12 years, 11 months
[libvirt] [PATCHv2 0/5] Add new command domiftune
by Hu Tao
This series adds a new command domiftune to get/set parameters of
domain's network interfaces. Supported parameters are bandwidth
settings.
Currently the network interface bandwidth can only be set:
- in domain's xml before the domain is up
- when attaching an interface by attach-interface
With this series, users can change network interface bandwidth
settings using virsh, whether the domain is running or not.
changes:
- rebase
- use vshGetTypedParamValue in patch 5
Hu Tao (5):
Add API virDomain{S,G}etInterfaceParameters
virDomain{S,G}etInterfaceParameters: the main entry points
Add virDomain{S,G}etInterfaceparameters support to the remote driver
Add virDomain{S,G}etInterfaceParameters support to qemu driver
Enable the virDomain{S,G}etInterfaceParameters in virsh
daemon/remote.c | 64 ++++++
include/libvirt/libvirt.h.in | 50 +++++
python/generator.py | 2 +
src/driver.h | 12 ++
src/libvirt.c | 118 ++++++++++++
src/libvirt_public.syms | 2 +
src/qemu/qemu_driver.c | 434 ++++++++++++++++++++++++++++++++++++++++++
src/remote/remote_driver.c | 52 +++++
src/remote/remote_protocol.x | 28 +++-
src/remote_protocol-structs | 24 +++
tools/virsh.c | 198 +++++++++++++++++++
tools/virsh.pod | 21 ++
12 files changed, 1004 insertions(+), 1 deletions(-)
--
1.7.4.4
12 years, 11 months
[libvirt] Issue with GVirDomainDisk setters
by Zeeshan Ali (Khattak)
Hi Christophe,
I just found out a small issue in GVirDomainDisk setter functions:
they always add a new attribute on each call rather than overriding
existing value. For example this Vala code:
disk.set_guest_device_type (DomainDiskGuestDeviceType.DISK);
disk.set_target_dev ("sdb");
...
disk.set_guest_device_type (DomainDiskGuestDeviceType.FLOPPY);
disk.set_target_dev ("fd");
Will generate following XML:
<disk type="file" device="disk" device="floppy">
<target dev="sdb" dev="fd"/>
...
</disk>
--
Regards,
Zeeshan Ali (Khattak)
FSF member#5124
12 years, 11 months
[libvirt] Release schedule for libvirt 0.9.9
by Daniel Veillard
Again trying to keep with the monthly schedule of libvirt releases
I suggest to enter the freeze on Friday 30 at the end of the week,
targetting a 0.9.9 release one week later by Jan 6.
There is a few patch set that we should try to get in:
- kvm guest capabilities from Taku Izumi
- more cancellable command in virsh by Michal
- patch set from Eric for per disk label override
- maybe the domiftune functions from Hu Tao
So let's focuse on reviewing, finalizing and pushing the existing
patch sets, it's not too big, but a lot of people are on vacations :-)
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
12 years, 11 months
[libvirt] [PATCH] qemu: Keep list of USB devices attached to domains
by Michal Privoznik
In order to avoid situation where a USB device is
in use by two domains, we must keep a list of already
attached devices like we do for PCI.
---
src/qemu/qemu_conf.h | 2 +
src/qemu/qemu_driver.c | 4 +
src/qemu/qemu_hostdev.c | 92 ++++++++++++++++++++++++++++--
src/qemu/qemu_hostdev.h | 4 +
src/qemu/qemu_hotplug.c | 17 +++++-
src/util/hostusb.c | 140 +++++++++++++++++++++++++++++++++++++++++++++++
src/util/hostusb.h | 18 ++++++
7 files changed, 269 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index f5a0f60..d8d7915 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -36,6 +36,7 @@
# include "security/security_manager.h"
# include "cgroup.h"
# include "pci.h"
+# include "hostusb.h"
# include "cpu_conf.h"
# include "driver.h"
# include "bitmap.h"
@@ -125,6 +126,7 @@ struct qemud_driver {
bool autoStartBypassCache;
pciDeviceList *activePciHostdevs;
+ usbDeviceList *activeUsbHostdevs;
virBitmapPtr reservedVNCPorts;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c908135..eeeb935 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -583,6 +583,9 @@ qemudStartup(int privileged) {
if ((qemu_driver->activePciHostdevs = pciDeviceListNew()) == NULL)
goto error;
+ if ((qemu_driver->activeUsbHostdevs = usbDeviceListNew()) == NULL)
+ goto error;
+
if (privileged) {
if (chown(qemu_driver->libDir, qemu_driver->user, qemu_driver->group) < 0) {
virReportSystemError(errno,
@@ -773,6 +776,7 @@ qemudShutdown(void) {
qemuDriverLock(qemu_driver);
pciDeviceListFree(qemu_driver->activePciHostdevs);
+ usbDeviceListFree(qemu_driver->activeUsbHostdevs);
virCapabilitiesFree(qemu_driver->caps);
virDomainObjListDeinit(&qemu_driver->domains);
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index 60401f0..c7adb1d 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -314,13 +314,30 @@ qemuPrepareHostPCIDevices(struct qemud_driver *driver,
}
-static int
-qemuPrepareHostUSBDevices(struct qemud_driver *driver ATTRIBUTE_UNUSED,
- virDomainDefPtr def)
+int
+qemuPrepareHostdevUSBDevices(struct qemud_driver *driver,
+ const char *name,
+ virDomainHostdevDefPtr *hostdevs,
+ int nhostdevs)
{
+ int ret = -1;
int i;
- for (i = 0 ; i < def->nhostdevs ; i++) {
- virDomainHostdevDefPtr hostdev = def->hostdevs[i];
+ usbDeviceList *list;
+ usbDevice *tmp;
+
+ /* To prevent situation where USB device is assigned to two domains
+ * we need to keep a list of currently assigned USB devices.
+ * This is done in several loops which cannot be joined into one big
+ * loop. See qemuPrepareHostdevPCIDevices()
+ */
+ if (!(list = usbDeviceListNew()))
+ goto cleanup;
+
+ /* Loop 1: build temporary list and validate no usb device
+ * is already taken
+ */
+ for (i = 0 ; i < nhostdevs ; i++) {
+ virDomainHostdevDefPtr hostdev = hostdevs[i];
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
continue;
@@ -339,13 +356,74 @@ qemuPrepareHostUSBDevices(struct qemud_driver *driver ATTRIBUTE_UNUSED,
hostdev->source.subsys.u.usb.bus = usbDeviceGetBus(usb);
hostdev->source.subsys.u.usb.device = usbDeviceGetDevno(usb);
- usbFreeDevice(usb);
+ if ((tmp = usbDeviceListFind(driver->activeUsbHostdevs, usb))) {
+ const char *other_name = usbDeviceGetUsedBy(tmp);
+
+ if (other_name)
+ qemuReportError(VIR_ERR_OPERATION_INVALID,
+ _("USB device %s is in use by domain %s"),
+ usbDeviceGetName(tmp), other_name);
+ else
+ qemuReportError(VIR_ERR_OPERATION_INVALID,
+ _("USB device %s is already in use"),
+ usbDeviceGetName(tmp));
+ usbFreeDevice(usb);
+ goto cleanup;
+ }
+
+ if (usbDeviceListAdd(list, usb) < 0) {
+ usbFreeDevice(usb);
+ goto cleanup;
+ }
+
}
}
- return 0;
+ /* Loop 2: Mark devices in temporary list as used by @name
+ * and add them do driver list. However, if something goes
+ * wrong, perform rollback.
+ */
+ for (i = 0; i < usbDeviceListCount(list); i++) {
+ tmp = usbDeviceListGet(list, i);
+ usbDeviceSetUsedBy(tmp, name);
+ if (usbDeviceListAdd(driver->activeUsbHostdevs, tmp) < 0) {
+ usbFreeDevice(tmp);
+ goto inactivedevs;
+ }
+ }
+
+ /* Loop 3: Temporary list was successfully merged with
+ * driver list, so steal all items to avoid freeing them
+ * in cleanup label.
+ */
+ while (usbDeviceListCount(list) > 0) {
+ tmp = usbDeviceListGet(list, 0);
+ usbDeviceListSteal(list, tmp);
+ }
+
+ ret = 0;
+ goto cleanup;
+
+inactivedevs:
+ /* Steal devices from driver->activeUsbHostdevs.
+ * We will free them later.
+ */
+ for (i = 0; i < usbDeviceListCount(list); i++) {
+ tmp = usbDeviceListGet(list, i);
+ usbDeviceListSteal(driver->activeUsbHostdevs, tmp);
+ }
+
+cleanup:
+ usbDeviceListFree(list);
+ return ret;
}
+static int
+qemuPrepareHostUSBDevices(struct qemud_driver *driver,
+ virDomainDefPtr def)
+{
+ return qemuPrepareHostdevUSBDevices(driver, def->name, def->hostdevs, def->nhostdevs);
+}
int qemuPrepareHostDevices(struct qemud_driver *driver,
virDomainDefPtr def)
diff --git a/src/qemu/qemu_hostdev.h b/src/qemu/qemu_hostdev.h
index 07d7de2..d852f5b 100644
--- a/src/qemu/qemu_hostdev.h
+++ b/src/qemu/qemu_hostdev.h
@@ -33,6 +33,10 @@ int qemuPrepareHostdevPCIDevices(struct qemud_driver *driver,
const char *name,
virDomainHostdevDefPtr *hostdevs,
int nhostdevs);
+int qemuPrepareHostdevUSBDevices(struct qemud_driver *driver,
+ const char *name,
+ virDomainHostdevDefPtr *hostdevs,
+ int nhostdevs);
int qemuPrepareHostDevices(struct qemud_driver *driver,
virDomainDefPtr def);
void qemuReattachPciDevice(pciDevice *dev, struct qemud_driver *driver);
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 4067bb0..f3597a1 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1097,6 +1097,9 @@ int qemuDomainAttachHostDevice(struct qemud_driver *driver,
/* Resolve USB product/vendor to bus/device */
if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB &&
hostdev->source.subsys.u.usb.vendor) {
+ if (qemuPrepareHostdevUSBDevices(driver, vm->def->name, &hostdev, 1) < 0)
+ goto error;
+
usbDevice *usb
= usbFindDevice(hostdev->source.subsys.u.usb.vendor,
hostdev->source.subsys.u.usb.product);
@@ -2068,6 +2071,7 @@ qemuDomainDetachHostUsbDevice(struct qemud_driver *driver,
{
virDomainHostdevDefPtr detach = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
+ usbDevice *usb;
int i, ret;
for (i = 0 ; i < vm->def->nhostdevs ; i++) {
@@ -2123,6 +2127,17 @@ qemuDomainDetachHostUsbDevice(struct qemud_driver *driver,
if (ret < 0)
return -1;
+ usb = usbGetDevice(detach->source.subsys.u.usb.bus,
+ detach->source.subsys.u.usb.device);
+ if (usb) {
+ usbDeviceListDel(driver->activeUsbHostdevs, usb);
+ usbFreeDevice(usb);
+ } else {
+ VIR_WARN("Unable to find device %03d.%03d in list of used USB devices",
+ detach->source.subsys.u.usb.bus,
+ detach->source.subsys.u.usb.device);
+ }
+
if (vm->def->nhostdevs > 1) {
memmove(vm->def->hostdevs + i,
vm->def->hostdevs + i + 1,
@@ -2162,7 +2177,7 @@ int qemuDomainDetachHostDevice(struct qemud_driver *driver,
switch (hostdev->source.subsys.type) {
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
ret = qemuDomainDetachHostPciDevice(driver, vm, dev, &detach);
- break;
+ break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
ret = qemuDomainDetachHostUsbDevice(driver, vm, dev, &detach);
break;
diff --git a/src/util/hostusb.c b/src/util/hostusb.c
index 1669e2f..92f52a2 100644
--- a/src/util/hostusb.c
+++ b/src/util/hostusb.c
@@ -49,6 +49,12 @@ struct _usbDevice {
char name[USB_ADDR_LEN]; /* domain:bus:slot.function */
char id[USB_ID_LEN]; /* product vendor */
char *path;
+ const char *used_by; /* name of the domain using this dev */
+};
+
+struct _usbDeviceList {
+ unsigned int count;
+ usbDevice **devs;
};
/* For virReportOOMError() and virReportSystemError() */
@@ -225,6 +231,22 @@ usbFreeDevice(usbDevice *dev)
}
+void usbDeviceSetUsedBy(usbDevice *dev,
+ const char *name)
+{
+ dev->used_by = name;
+}
+
+const char * usbDeviceGetUsedBy(usbDevice *dev)
+{
+ return dev->used_by;
+}
+
+const char *usbDeviceGetName(usbDevice *dev)
+{
+ return dev->name;
+}
+
unsigned usbDeviceGetBus(usbDevice *dev)
{
return dev->bus;
@@ -243,3 +265,121 @@ int usbDeviceFileIterate(usbDevice *dev,
{
return (actor)(dev, dev->path, opaque);
}
+
+usbDeviceList *
+usbDeviceListNew(void)
+{
+ usbDeviceList *list;
+
+ if (VIR_ALLOC(list) < 0) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ return list;
+}
+
+void
+usbDeviceListFree(usbDeviceList *list)
+{
+ int i;
+
+ if (!list)
+ return;
+
+ for (i = 0; i < list->count; i++)
+ usbFreeDevice(list->devs[i]);
+
+ VIR_FREE(list->devs);
+ VIR_FREE(list);
+}
+
+int
+usbDeviceListAdd(usbDeviceList *list,
+ usbDevice *dev)
+{
+ if (usbDeviceListFind(list, dev)) {
+ usbReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Device %s is already in use"),
+ dev->name);
+ return -1;
+ }
+
+ if (VIR_REALLOC_N(list->devs, list->count+1) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+
+ list->devs[list->count++] = dev;
+
+ return 0;
+}
+
+usbDevice *
+usbDeviceListGet(usbDeviceList *list,
+ int idx)
+{
+ if (idx >= list->count ||
+ idx < 0)
+ return NULL;
+
+ return list->devs[idx];
+}
+
+int
+usbDeviceListCount(usbDeviceList *list)
+{
+ return list->count;
+}
+
+usbDevice *
+usbDeviceListSteal(usbDeviceList *list,
+ usbDevice *dev)
+{
+ usbDevice *ret = NULL;
+ int i;
+
+ for (i = 0; i < list->count; i++) {
+ if (list->devs[i]->bus != dev->bus ||
+ list->devs[i]->dev != dev->dev)
+ continue;
+
+ ret = list->devs[i];
+
+ if (i != list->count--)
+ memmove(&list->devs[i],
+ &list->devs[i+1],
+ sizeof(*list->devs) * (list->count - i));
+
+ if (VIR_REALLOC_N(list->devs, list->count) < 0) {
+ ; /* not fatal */
+ }
+
+ break;
+ }
+ return ret;
+}
+
+void
+usbDeviceListDel(usbDeviceList *list,
+ usbDevice *dev)
+{
+ usbDevice *ret = usbDeviceListSteal(list, dev);
+ if (ret)
+ usbFreeDevice(ret);
+}
+
+usbDevice *
+usbDeviceListFind(usbDeviceList *list,
+ usbDevice *dev)
+{
+ int i;
+
+ for (i = 0; i < list->count; i++) {
+ if (list->devs[i]->bus == dev->bus &&
+ list->devs[i]->dev == dev->dev)
+ return list->devs[i];
+ }
+
+ return NULL;
+}
diff --git a/src/util/hostusb.h b/src/util/hostusb.h
index f4a13ca..afaa32f 100644
--- a/src/util/hostusb.h
+++ b/src/util/hostusb.h
@@ -17,6 +17,7 @@
*
* Authors:
* Daniel P. Berrange <berrange(a)redhat.com>
+ * Michal Privoznik <mprivozn(a)redhat.com>
*/
#ifndef __VIR_USB_H__
@@ -25,12 +26,16 @@
# include "internal.h"
typedef struct _usbDevice usbDevice;
+typedef struct _usbDeviceList usbDeviceList;
usbDevice *usbGetDevice(unsigned bus,
unsigned devno);
usbDevice *usbFindDevice(unsigned vendor,
unsigned product);
void usbFreeDevice (usbDevice *dev);
+void usbDeviceSetUsedBy(usbDevice *dev, const char *name);
+const char *usbDeviceGetUsedBy(usbDevice *dev);
+const char *usbDeviceGetName(usbDevice *dev);
unsigned usbDeviceGetBus(usbDevice *dev);
unsigned usbDeviceGetDevno(usbDevice *dev);
@@ -49,5 +54,18 @@ int usbDeviceFileIterate(usbDevice *dev,
usbDeviceFileActor actor,
void *opaque);
+usbDeviceList *usbDeviceListNew(void);
+void usbDeviceListFree(usbDeviceList *list);
+int usbDeviceListAdd(usbDeviceList *list,
+ usbDevice *dev);
+usbDevice * usbDeviceListGet(usbDeviceList *list,
+ int idx);
+int usbDeviceListCount(usbDeviceList *list);
+usbDevice * usbDeviceListSteal(usbDeviceList *list,
+ usbDevice *dev);
+void usbDeviceListDel(usbDeviceList *list,
+ usbDevice *dev);
+usbDevice * usbDeviceListFind(usbDeviceList *list,
+ usbDevice *dev);
#endif /* __VIR_USB_H__ */
--
1.7.3.4
12 years, 11 months
[libvirt] [PATCH] docs: fix missing / in xml examples
by Eric Blake
* docs/formatdomain.html.in: Fix typos in examples.
---
Pushing under the trivial rule.
docs/formatdomain.html.in | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 9cf0f12..06181b1 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -947,7 +947,7 @@
<devices>
<disk type='file' snapshot='external'>
<driver name="tap" type="aio" cache="default"/>
- <source file='/var/lib/xen/images/fv0'/ startupPolicy='optional'>
+ <source file='/var/lib/xen/images/fv0'/ startupPolicy='optional'/>
<target dev='hda' bus='ide'/>
<iotune>
<total_bytes_sec>10000000</total_bytes_sec>
@@ -2980,7 +2980,7 @@ qemu-kvm -net nic,model=? /dev/null
...
<devices>
<console type='stdio'>
- <target port='1'>
+ <target port='1'/>
</console>
</devices>
...</pre>
--
1.7.7.4
12 years, 11 months
[libvirt] [libvirt-glib] API to suspend a domain
by Zeeshan Ali (Khattak)
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
---
libvirt-gobject/libvirt-gobject-domain.c | 30 ++++++++++++++++++++++++++++++
libvirt-gobject/libvirt-gobject-domain.h | 3 +++
libvirt-gobject/libvirt-gobject.sym | 1 +
3 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
index 4301b14..0b52538 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -678,3 +678,33 @@ gboolean gvir_domain_open_graphics(GVirDomain *dom,
cleanup:
return ret;
}
+
+/**
+ * gir_domain_suspend:
+ * @dom: the domain to suspend
+ * @err: Place-holder for possible errors
+ *
+ * Suspends an active domain, the process is frozen without further access to
+ * CPU resources and I/O but the memory used by the domain at the hypervisor
+ * level will stay allocated. Use gvir_domain_resume() to reactivate the domain.
+ *
+ * Returns: TRUE if domain was saved successfully, FALSE otherwise.
+ */
+gboolean gvir_domain_suspend (GVirDomain *dom,
+ GError **err)
+{
+ gboolean ret = FALSE;
+
+ g_return_val_if_fail(GVIR_IS_DOMAIN(dom), FALSE);
+
+ if (virDomainSuspend(dom->priv->handle) < 0) {
+ gvir_set_error_literal(err, GVIR_DOMAIN_ERROR,
+ 0,
+ "Unable to suspend domain");
+ goto cleanup;
+ }
+
+ ret = TRUE;
+cleanup:
+ return ret;
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h
index 6fcec8d..a5923f4 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -153,6 +153,9 @@ gboolean gvir_domain_open_graphics(GVirDomain *dom,
unsigned int flags,
GError **err);
+gboolean gvir_domain_suspend (GVirDomain *dom,
+ GError **err);
+
G_END_DECLS
#endif /* __LIBVIRT_GOBJECT_DOMAIN_H__ */
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index a523adc..526098d 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -51,6 +51,7 @@ LIBVIRT_GOBJECT_0.0.3 {
gvir_domain_start;
gvir_domain_resume;
gvir_domain_stop;
+ gvir_domain_suspend;
gvir_domain_delete;
gvir_domain_open_console;
gvir_domain_open_graphics;
--
1.7.7.4
12 years, 11 months