[libvirt] [PATCH 8/8] Support virDomainGetBlockIoThrottle in the python API
by Lei Li
Signed-off-by:Zhi Yong Wu <wuzhy(a)linux.vnet.ibm.com>
Signed-off-by: Lei Li <lilei(a)linux.vnet.ibm.com>
---
python/generator.py | 2 +
python/libvirt-override-api.xml | 16 ++++++++++++++
python/libvirt-override.c | 43 +++++++++++++++++++++++++++++++++++++++
3 files changed, 61 insertions(+), 0 deletions(-)
diff --git a/python/generator.py b/python/generator.py
index 71afdb7..9d786c4 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -414,6 +414,8 @@ skip_impl = (
'virDomainGetBlockJobInfo',
'virDomainMigrateGetMaxSpeed',
'virDomainBlockStatsFlags',
+ 'virDomainSetBlockIoThrottle',
+ 'virDomainGetBlockIoThrottle',
)
qemu_skip_impl = (
diff --git a/python/libvirt-override-api.xml b/python/libvirt-override-api.xml
index ef02f34..5d85923 100644
--- a/python/libvirt-override-api.xml
+++ b/python/libvirt-override-api.xml
@@ -375,5 +375,21 @@
<arg name='flags' type='unsigned int' info='flags, currently unused, pass 0.'/>
<return type='unsigned long' info='current max migration speed, or None in case of error'/>
</function>
+ <function name='virDomainSetBlockIoThrottle' file='python'>
+ <info>Change the I/O throttle for a block device</info>
+ <arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
+ <arg name='disk' type='const char *' info='disk name'/>
+ <arg name='info' type='virDomainBlockIoThrottleInfoPtr' info='io throttle limits'/>
+ <arg name='flags' type='unsigned int' info='0 on display, 1 on set.'/>
+ <return type='virDomainSetBlockIoThrottleInfo' info='0 in case of operation has started, -1 in case of failure'/>
+ </function>
+ <function name='virDomainGetBlockIoThrottle' file='python'>
+ <info>Get the I/O throttle for a block device</info>
+ <arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
+ <arg name='disk' type='const char *' info='disk name'/>
+ <arg name='reply' type='virDomainBlockIoThrottleInfoPtr' info='io throttle info'/>
+ <arg name='flags' type='unsigned int' info='0 on display, 1 on set.'/>
+ <return type='virDomainGetBlockIoThrottleInfo' info='A dictionary containing block I/O limits information.'/>
+ </function>
</symbols>
</api>
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 1759bae..c005cf0 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -3195,6 +3195,48 @@ LIBVIRT_END_ALLOW_THREADS;
return ret;
}
+static PyObject *
+libvirt_virDomainGetBlockIoThrottle(PyObject *self ATTRIBUTE_UNUSED,
+ PyObject *args)
+{
+ virDomainPtr domain;
+ PyObject *pyobj_domain;
+ const char *disk;
+ unsigned int flags;
+ virDomainBlockIoThrottleInfo reply;
+ int c_ret;
+ PyObject *ret;
+
+ if (!PyArg_ParseTuple(args, (char *)"Ozi:virDomainGetBlockIoThrottle",
+ &pyobj_domain, &disk, &flags))
+ return(NULL);
+ domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+LIBVIRT_BEGIN_ALLOW_THREADS;
+ c_ret = virDomainGetBlockIoThrottle(domain, disk, &reply, flags);
+LIBVIRT_END_ALLOW_THREADS;
+
+ if (c_ret != 1)
+ return VIR_PY_NONE;
+
+ if ((ret = PyDict_New()) == NULL)
+ return VIR_PY_NONE;
+
+ PyDict_SetItem(ret, libvirt_constcharPtrWrap("bps"),
+ libvirt_intWrap(reply.bps));
+ PyDict_SetItem(ret, libvirt_constcharPtrWrap("bps_rd"),
+ libvirt_intWrap(reply.bps_rd));
+ PyDict_SetItem(ret, libvirt_constcharPtrWrap("bps_wr"),
+ libvirt_intWrap(reply.bps_wr));
+ PyDict_SetItem(ret, libvirt_constcharPtrWrap("iops"),
+ libvirt_intWrap(reply.iops));
+ PyDict_SetItem(ret, libvirt_constcharPtrWrap("iops_rd"),
+ libvirt_intWrap(reply.iops_rd));
+ PyDict_SetItem(ret, libvirt_constcharPtrWrap("iops_wr"),
+ libvirt_intWrap(reply.iops_wr));
+ return ret;
+}
+
/*******************************************
* Helper functions to avoid importing modules
* for every callback
@@ -4837,6 +4879,7 @@ static PyMethodDef libvirtMethods[] = {
{(char *) "virDomainSnapshotListNames", libvirt_virDomainSnapshotListNames, METH_VARARGS, NULL},
{(char *) "virDomainRevertToSnapshot", libvirt_virDomainRevertToSnapshot, METH_VARARGS, NULL},
{(char *) "virDomainGetBlockJobInfo", libvirt_virDomainGetBlockJobInfo, METH_VARARGS, NULL},
+ {(char *) "virDomainGetBlockIoThrottle", libvirt_virDomainGetBlockIoThrottle, METH_VARARGS, NULL},
{(char *) "virDomainSendKey", libvirt_virDomainSendKey, METH_VARARGS, NULL},
{(char *) "virDomainMigrateGetMaxSpeed", libvirt_virDomainMigrateGetMaxSpeed, METH_VARARGS, NULL},
{NULL, NULL, 0, NULL}
--
1.7.1
13 years, 1 month
[libvirt] [RFC PATCH 0/8 v2] Summary on block IO throttle
by Lei Li
Changes since V1
- Implement the support to get the block io throttling for
a device as read only connection - QMP/HMP.
- Split virDomainBlockIoThrottle into two separate functions
virDomainSetBlockIoThrottle - Set block I/O limits for a device
- Requires a connection in 'write' mode.
- Limits (info) structure passed as an input parameter
virDomainGetBlockIoThrottle - Get the current block I/O limits for a device
- Works on a read-only connection.
- Current limits are written to the output parameter (reply).
- And Other fixups suggested by Adam Litke, Daniel P. Berrange.
- For dynamically allocate the blkiothrottle struct, I will fix
it when implement --current --live --config options support.
Today libvirt supports the cgroups blkio-controller, which handles
proportional shares and throughput/iops limits on host block devices.
blkio-controller does not support network file systems (NFS) or other
QEMU remote block drivers (curl, Ceph/rbd, sheepdog) since they are
not host block devices. QEMU I/O throttling works with all types of
drive and can be applied independently to each drive attached to
a guest and supports throughput/iops limits.
To help add QEMU I/O throttling support to libvirt, we plan to complete
it with add new API virDomainBlockIoThrottle(), new command 'blkiothrottle'
and Python bindings.
Notes: we are sending this series out now(even though they are not completed
yet.)because we want to start the review process. #1)#2) features were implemented
by Zhi Yong Wu:
1) Enable the blkio throttling in xml when guest is starting up.
Add blkio throttling in xml as follows:
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/var/lib/libvirt/images/kvm-one.img'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
<iotune bps='n'.../>
</disk>
2) Enable blkio throttling setting at guest running time.
virsh blkiothrottle <domain> <device> [--bps<number>] [--bps_rd<number>] \
[--bps_wr<number>] [--iops<number>] [--iops_rd<number>] [--iops_wr<number>]
3) The support to get the current block i/o throttling for a device - HMP/QMP.
virsh blkiothrottle <domain> <device>
bps:
bps_rd:
bps_wr:
iops:
iops_rd:
iops_wr:
And I will address feedback and work on the missing features in few days includes:
4) Python binding support for setting blkio throttling.
5) --current --live --config options support to unify the libvirt API.
daemon/remote.c | 85 +++++++++++++++++
include/libvirt/libvirt.h.in | 25 +++++
python/generator.py | 2 +
python/libvirt-override-api.xml | 16 ++++
python/libvirt-override.c | 43 +++++++++
src/conf/domain_conf.c | 77 ++++++++++++++++
src/conf/domain_conf.h | 11 +++
src/driver.h | 18 ++++
src/libvirt.c | 120 ++++++++++++++++++++++++
src/libvirt_public.syms | 2 +
src/qemu/qemu_command.c | 35 +++++++
src/qemu/qemu_driver.c | 108 ++++++++++++++++++++++
src/qemu/qemu_monitor.c | 36 ++++++++
src/qemu/qemu_monitor.h | 10 ++
src/qemu/qemu_monitor_json.c | 191 +++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 10 ++
src/qemu/qemu_monitor_text.c | 88 ++++++++++++++++++
src/qemu/qemu_monitor_text.h | 10 ++
src/remote/remote_driver.c | 81 +++++++++++++++++
src/remote/remote_protocol.x | 39 ++++++++-
src/remote_protocol-structs | 34 +++++++
src/util/xml.h | 3 +
tools/virsh.c | 100 ++++++++++++++++++++
tools/virsh.pod | 13 +++
24 files changed, 1156 insertions(+), 1 deletions(-)
--
Lei
13 years, 1 month
[libvirt] [PATCH] Fix typo in virFileAccessibleAs
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Pushing as a Win32 build breaker
* src/util/util.c: s/git_t/gid_t/ in parameter list of virFileAccessibleAs
---
src/util/util.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/util/util.c b/src/util/util.c
index bf170f2..ae0dc56 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -1058,7 +1058,7 @@ int
virFileAccessibleAs(const char *path,
int mode,
uid_t uid ATTRIBUTE_UNUSED,
- git_t gid ATTRIBUTE_UNUSED)
+ gid_t gid ATTRIBUTE_UNUSED)
{
VIR_WARN("Ignoring uid/gid due to WIN32");
--
1.7.6.4
13 years, 1 month
[libvirt] [libvirt-glib 1/2] Add API to build & start storage pools
by Zeeshan Ali (Khattak)
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
---
libvirt-gobject/libvirt-gobject-storage-pool.c | 44 ++++++++++++++++++++++++
libvirt-gobject/libvirt-gobject-storage-pool.h | 8 ++++
libvirt-gobject/libvirt-gobject.sym | 2 +
3 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c
index bd3be94..74ecabc 100644
--- a/libvirt-gobject/libvirt-gobject-storage-pool.c
+++ b/libvirt-gobject/libvirt-gobject-storage-pool.c
@@ -518,3 +518,47 @@ GVirStorageVol *gvir_storage_pool_create_volume
return g_object_ref(volume);
}
+
+/**
+ * gvir_storage_pool_build:
+ * @pool: the storage pool to build
+ * @flags: the flags
+ * @err: return location for any #GError
+ *
+ * Return value: #True on success, #False otherwise.
+ */
+gboolean gvir_storage_pool_build (GVirStoragePool *pool,
+ guint64 flags G_GNUC_UNUSED,
+ GError **err)
+{
+ if (virStoragePoolBuild(pool->priv->handle, 0)) {
+ *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR,
+ flags,
+ "Failed to build storage pool");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/**
+ * gvir_storage_pool_start:
+ * @pool: the storage pool to start
+ * @flags: the flags
+ * @err: return location for any #GError
+ *
+ * Return value: #True on success, #False otherwise.
+ */
+gboolean gvir_storage_pool_start (GVirStoragePool *pool,
+ guint64 flags G_GNUC_UNUSED,
+ GError **err)
+{
+ if (virStoragePoolCreate(pool->priv->handle, 0)) {
+ *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR,
+ flags,
+ "Failed to start storage pool");
+ return FALSE;
+ }
+
+ return TRUE;
+}
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.h b/libvirt-gobject/libvirt-gobject-storage-pool.h
index 620f888..7b13ef9 100644
--- a/libvirt-gobject/libvirt-gobject-storage-pool.h
+++ b/libvirt-gobject/libvirt-gobject-storage-pool.h
@@ -88,6 +88,14 @@ GVirStorageVol *gvir_storage_pool_create_volume
GVirConfigStorageVol *conf,
GError **err);
+gboolean gvir_storage_pool_build (GVirStoragePool *pool,
+ guint64 flags,
+ GError **err);
+
+gboolean gvir_storage_pool_start (GVirStoragePool *pool,
+ guint64 flags,
+ GError **err);
+
G_END_DECLS
#endif /* __LIBVIRT_GOBJECT_STORAGE_POOL_H__ */
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index f1fa78b..4b1b84c 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -89,6 +89,8 @@ LIBVIRT_GOBJECT_0.0.1 {
gvir_storage_pool_get_volumes;
gvir_storage_pool_get_volume;
gvir_storage_pool_create_volume;
+ gvir_storage_pool_build;
+ gvir_storage_pool_start;
gvir_storage_vol_get_type;
gvir_storage_vol_handle_get_type;
--
1.7.6.4
13 years, 1 month
Re: [libvirt] [RFC PATCH v3 0/4] Improve Ceph Qemu+RBD support
by Sage Weil
Hi Daniel,
Is this iteration closer to what you had in mind?
Obscuring the passing of secrets into qemu is going to need changes on the
qemu end, but it would be great to get authentication at least working in
the meantime.
sage
On Thu, 20 Oct 2011, Josh Durgin wrote:
> The current support for qemu and Ceph RBD (rados block device) has two
> main deficiencies: authentication doesn't work, and it relies on
> environment variables (which don't work with latest upstream). This
> patch set addresses both those problems.
>
> The first two patches update the xml schemas and conf to add a Ceph
> secret type and to specify authentication information along with the
> rbd disk.
>
> The next patch passes virConnectPtr into the Domain{Attach,Detach}
> methods (needed to access secrets while building the qemu command).
>
> The final patch replaces the current RBD qemu code and uses the new
> conf info to do authentication properly. We still need to make a
> change there to avoid having the authentication key show up on qemu
> command line (there are a few ways to do this, which will be discussed
> in a separate email).
>
> Changes from v2:
> make <auth> a direct child of <disk> instead of <source>
> allow secret lookup by UUID or usage
> test with fake secret driver
> other fixes from Daniel's review
>
> Changes from v1:
> update docs/schemas/{domain,secret}.rng
>
> Josh Durgin (1):
> storage: add auth to virDomainDiskDef
>
> Sage Weil (3):
> secret: add Ceph secret type
> qemu: pass virConnectPtr into Domain{Attach,Detach}*
> qemu/rbd: improve rbd device specification
>
> docs/schemas/domaincommon.rng | 29 ++
> docs/schemas/secret.rng | 10 +
> include/libvirt/libvirt.h.in | 3 +
> src/Makefile.am | 3 +-
> src/conf/domain_conf.c | 105 +++++++-
> src/conf/domain_conf.h | 17 ++
> src/conf/secret_conf.c | 23 ++-
> src/conf/secret_conf.h | 1 +
> src/qemu/qemu_command.c | 289 ++++++++++++--------
> src/qemu/qemu_command.h | 3 +-
> src/qemu/qemu_driver.c | 17 +-
> src/qemu/qemu_hotplug.c | 15 +-
> src/qemu/qemu_hotplug.h | 9 +-
> src/secret/secret_driver.c | 8 +
> .../qemuxml2argv-disk-drive-network-rbd-auth.args | 6 +
> .../qemuxml2argv-disk-drive-network-rbd-auth.xml | 37 +++
> .../qemuxml2argv-disk-drive-network-rbd.args | 6 +-
> tests/qemuxml2argvtest.c | 52 ++++
> 18 files changed, 485 insertions(+), 148 deletions(-)
> create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth.args
> create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth.xml
>
> --
> To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
> the body of a message to majordomo(a)vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
13 years, 1 month
[libvirt] [PATCH] qemu: simplify use of HAVE_YAJL
by Eric Blake
Rather than making all clients of monitor commands that are JSON-only
check whether yajl support was compiled in, it is simpler to just
avoid setting the capability bit up front if we can't use the capability.
* src/qemu/qemu_capabilities.c (qemuCapsComputeCmdFlags): Only set
capability bit if we also have yajl library to use it.
* src/qemu/qemu_driver.c (qemuDomainReboot): Drop #ifdefs.
* src/qemu/qemu_process.c (qemuProcessStart): Likewise.
---
As mentioned here:
https://www.redhat.com/archives/libvir-list/2011-October/msg01004.html
src/qemu/qemu_capabilities.c | 2 ++
src/qemu/qemu_driver.c | 6 ------
src/qemu/qemu_process.c | 2 --
3 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 5f0356c..b4ab55b 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1060,8 +1060,10 @@ qemuCapsComputeCmdFlags(const char *help,
* two features. The benefits of JSON mode now outweigh
* the downside.
*/
+#if HAVE_YAJL
if (version >= 13000)
qemuCapsSet(flags, QEMU_CAPS_MONITOR_JSON);
+#endif
if (version >= 13000)
qemuCapsSet(flags, QEMU_CAPS_PCI_MULTIFUNCTION);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0a0a34a..55a9652 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1538,9 +1538,7 @@ static int qemuDomainReboot(virDomainPtr dom, unsigned int flags) {
struct qemud_driver *driver = dom->conn->privateData;
virDomainObjPtr vm;
int ret = -1;
-#if HAVE_YAJL
qemuDomainObjPrivatePtr priv;
-#endif
virCheckFlags(0, -1);
@@ -1556,7 +1554,6 @@ static int qemuDomainReboot(virDomainPtr dom, unsigned int flags) {
goto cleanup;
}
-#if HAVE_YAJL
priv = vm->privateData;
if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MONITOR_JSON)) {
@@ -1586,12 +1583,9 @@ static int qemuDomainReboot(virDomainPtr dom, unsigned int flags) {
if (qemuDomainObjEndJob(driver, vm) == 0)
vm = NULL;
} else {
-#endif
qemuReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("Reboot is not supported without the JSON monitor"));
-#if HAVE_YAJL
}
-#endif
cleanup:
if (vm)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index a7fe86c..cc2395f 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2962,11 +2962,9 @@ int qemuProcessStart(virConnectPtr conn,
if (qemuProcessPrepareMonitorChr(driver, priv->monConfig, vm->def->name) < 0)
goto cleanup;
-#if HAVE_YAJL
if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MONITOR_JSON))
priv->monJSON = 1;
else
-#endif
priv->monJSON = 0;
priv->monError = false;
--
1.7.4.4
13 years, 1 month
[libvirt] [PATCHv2 00/13] fix <domainsnapshot> indentation
by Eric Blake
A rather revamped series, based on comments from v1:
https://www.redhat.com/archives/libvir-list/2011-September/msg00916.html
Implementing auto-indent as part of virBuffer indeed makes things
easier - I no longer have to pass around an explicit indent parameter,
since it is instead part of the virBufferPtr already being passed.
If you are trying to compare to the v1 thread, the correlation is:
1 - new to this series
2 - split out from 1/14
3 - new to this series
4 - new to this series
5 - compare to 2/14
6 - compare to 14/14
7 - compare to 4/14
8 - compare to 5/14
9 - compare to 9/14
10 - compare to 11/14
11 - compare to 10/14
12 - folds in changes from 3, 6, 7, 8, 12, 13/14
13 - compare to 1/14, although I'm okay with ditching this one now
With just patches 1-12, there is a net reduction in lines of code in
src/ (the overall series adds lines, but that's thanks to tests/).
Eric Blake (13):
virbuf: fix const-correctness
virbuf: improve testsuite reporting
virbuf: more detailed error reporting
virbuf: add auto-indentation support
snapshot: indent domain xml when nesting
snapshot: test domainsnapshot indentation
snapshot: simplify indentation of sysinfo
snapshot: simplify indentation of cpu features
snapshot: simplify indentation of network xml
snapshot: simplify indentation of nwfilter
snapshot: simplify indentation of disk encryption xml
snapshot: minor cleanups from reviewing indentation
virbuf: add explicit indentation functions
.gitignore | 1 +
src/conf/capabilities.c | 8 +-
src/conf/cpu_conf.c | 42 +--
src/conf/cpu_conf.h | 9 +-
src/conf/domain_conf.c | 268 +++++++-------
src/conf/domain_conf.h | 5 +-
src/conf/network_conf.c | 14 +-
src/conf/nwfilter_conf.c | 18 +-
src/conf/nwfilter_params.c | 45 +--
src/conf/nwfilter_params.h | 7 +-
src/conf/storage_conf.c | 9 +-
src/conf/storage_encryption_conf.c | 20 +-
src/conf/storage_encryption_conf.h | 5 +-
src/cpu/cpu.c | 2 +-
src/libvirt_private.syms | 6 +
src/qemu/qemu_driver.c | 9 +-
src/qemu/qemu_migration.c | 25 +-
src/util/buf.c | 258 +++++++++----
src/util/buf.h | 46 ++-
src/util/network.c | 49 +--
src/util/network.h | 11 +-
src/util/sysinfo.c | 399 +++++++--------------
src/util/sysinfo.h | 3 +-
tests/Makefile.am | 14 +-
tests/cputest.c | 2 +-
tests/domainsnapshotxml2xmlout/all_parameters.xml | 2 +-
tests/domainsnapshotxml2xmlout/disk_snapshot.xml | 102 +++---
tests/domainsnapshotxml2xmlout/full_domain.xml | 52 ++--
tests/domainsnapshotxml2xmltest.c | 128 +++++++
tests/testutils.c | 2 +-
tests/virbuftest.c | 123 ++++++-
31 files changed, 949 insertions(+), 735 deletions(-)
create mode 100644 tests/domainsnapshotxml2xmltest.c
--
1.7.4.4
13 years, 1 month
[libvirt] [PATCH] storage: avoid null deref on qemu-img failure
by Eric Blake
Detected by Coverity. Only possible if qemu-img gives bogus output,
but we might as well be robust.
* src/storage/storage_backend.c
(virStorageBackendQEMUImgBackingFormat): Check for strstr failure.
---
src/storage/storage_backend.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 64c35c2..7c8bfdc 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -631,8 +631,9 @@ static int virStorageBackendQEMUImgBackingFormat(const char *qemuimg)
if (virCommandRun(cmd, &exitstatus) < 0)
goto cleanup;
- start = strstr(help, " create ");
- end = strstr(start, "\n");
+ if ((start = strstr(help, " create ")) == NULL ||
+ (end = strstr(start, "\n")) == NULL)
+ goto cleanup;
if (((tmp = strstr(start, "-F fmt")) && tmp < end) ||
((tmp = strstr(start, "-F backing_fmt")) && tmp < end))
ret = QEMU_IMG_BACKING_FORMAT_FLAG;
--
1.7.4.4
13 years, 1 month
[libvirt] [libosinfo 1/2] Add gvir_connection_create_storage_pool()
by Zeeshan Ali (Khattak)
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
API to create new storage pools.
---
libvirt-gobject/libvirt-gobject-connection.c | 40 ++++++++++++++++++++++++++
libvirt-gobject/libvirt-gobject-connection.h | 6 ++++
libvirt-gobject/libvirt-gobject.sym | 1 +
3 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c
index 30b7792..43a262a 100644
--- a/libvirt-gobject/libvirt-gobject-connection.c
+++ b/libvirt-gobject/libvirt-gobject-connection.c
@@ -1201,3 +1201,43 @@ GVirDomain *gvir_connection_create_domain(GVirConnection *conn,
return g_object_ref(domain);
}
+
+/**
+ * gvir_connection_create_storage_pool:
+ * @conn: the connection on which to create the pool
+ * @conf: the configuration for the new storage pool
+ * Returns: (transfer full): the newly created storage pool
+ */
+GVirStoragePool *gvir_connection_create_storage_pool
+ (GVirConnection *conn,
+ GVirConfigStoragePool *conf,
+ GError **err) {
+ const gchar *xml;
+ virStoragePoolPtr handle;
+ GVirConnectionPrivate *priv = conn->priv;
+
+ xml = gvir_config_object_get_doc(GVIR_CONFIG_OBJECT(conf));
+
+ g_return_val_if_fail(xml != NULL, NULL);
+
+ if (!(handle = virStoragePoolDefineXML(priv->conn, xml, 0))) {
+ *err = gvir_error_new_literal(GVIR_CONNECTION_ERROR,
+ 0,
+ "Failed to create storage pool");
+ return NULL;
+ }
+
+ GVirStoragePool *pool;
+
+ pool = GVIR_STORAGE_POOL(g_object_new(GVIR_TYPE_STORAGE_POOL,
+ "handle", handle,
+ NULL));
+
+ g_mutex_lock(priv->lock);
+ g_hash_table_insert(priv->pools,
+ (gpointer)gvir_storage_pool_get_uuid(pool),
+ pool);
+ g_mutex_unlock(priv->lock);
+
+ return g_object_ref(pool);
+}
diff --git a/libvirt-gobject/libvirt-gobject-connection.h b/libvirt-gobject/libvirt-gobject-connection.h
index 8c1d1a4..3a8d888 100644
--- a/libvirt-gobject/libvirt-gobject-connection.h
+++ b/libvirt-gobject/libvirt-gobject-connection.h
@@ -160,6 +160,12 @@ GVirStoragePool *gvir_connection_get_storage_pool(GVirConnection *conn,
GVirStoragePool *gvir_connection_find_storage_pool_by_name(GVirConnection *conn,
const gchar *name);
+GVirStoragePool *gvir_connection_create_storage_pool
+ (GVirConnection *conn,
+ GVirConfigStoragePool *conf,
+ GError **err);
+
+
GVirStream *gvir_connection_get_stream(GVirConnection *conn,
gint flags);
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index e019e22..f1fa78b 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -27,6 +27,7 @@ LIBVIRT_GOBJECT_0.0.1 {
gvir_connection_find_domain_by_name;
gvir_connection_find_storage_pool_by_name;
gvir_connection_create_domain;
+ gvir_connection_create_storage_pool;
gvir_domain_get_type;
gvir_domain_handle_get_type;
--
1.7.6.4
13 years, 1 month