[libvirt] [PATCH] util: Fix coverity warings in virProcessGetAffinity
by Peter Krempa
Refactor the code flow a bit more to clear coverity errors.
Store the cpu count in an intermediate variable and reuse it rather than
caluclating the index.
---
src/util/virprocess.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index a38cb75..c07e5cd 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -474,12 +474,14 @@ virProcessGetAffinity(pid_t pid)
size_t i;
cpu_set_t *mask;
size_t masklen;
+ size_t ncpus;
virBitmapPtr ret = NULL;
# ifdef CPU_ALLOC
/* 262144 cpus ought to be enough for anyone */
- masklen = CPU_ALLOC_SIZE(1024 << 8);
- mask = CPU_ALLOC(1024 << 8);
+ ncpus = 1024 << 8;
+ masklen = CPU_ALLOC_SIZE(ncpus);
+ mask = CPU_ALLOC(ncpus);
if (!mask) {
virReportOOMError();
@@ -488,6 +490,7 @@ virProcessGetAffinity(pid_t pid)
CPU_ZERO_S(masklen, mask);
# else
+ ncpus = 1024;
if (VIR_ALLOC(mask) < 0)
return NULL;
@@ -501,10 +504,10 @@ virProcessGetAffinity(pid_t pid)
goto cleanup;
}
- if (!(ret = virBitmapNew(masklen * 8)))
+ if (!(ret = virBitmapNew(ncpus)))
goto cleanup;
- for (i = 0; i < masklen * 8; i++) {
+ for (i = 0; i < ncpus; i++) {
# ifdef CPU_ALLOC
if (CPU_ISSET_S(i, masklen, mask))
ignore_value(virBitmapSetBit(ret, i));
--
2.4.1
9 years, 5 months
[libvirt] [PATCH v2 0/2] qemu-nbd cleanup, resent
by Cédric Bosdonnat
Hi all,
Note: I'm just resending this as the patches somehow never landed on the mailing list.
Here is the very same patch, but split in two patches. Well, I also moved
two comments around between v1 and v2.
Cédric Bosdonnat (2):
Add virProcessGetPids to get all tasks of a process
lxc: properly clean up qemu-nbd
src/libvirt_private.syms | 1 +
src/lxc/lxc_controller.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++
src/util/virprocess.c | 47 ++++++++++++++++++++++++++++++++++++++++
src/util/virprocess.h | 2 ++
4 files changed, 106 insertions(+)
--
2.1.4
9 years, 5 months
[libvirt] [PATCHv2] qemu: add a check for slot and base when build dimm address
by Luyao Huang
When hot-plug a memory device, we don't check if there
is a memory device have the same address with the memory device
we want hot-pluged. Qemu forbid use/hot-plug 2 memory device
with same slot or the same base(qemu side this elemnt named addr).
Introduce a address check when build memory device qemu command line.
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
v2:
move the check to qemuBuildMemoryDeviceStr() to check the dimm address
when start/hot-plug a memory device.
src/qemu/qemu_command.c | 77 ++++++++++++++++++++++++++++++++++++-------------
1 file changed, 57 insertions(+), 20 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d8ce511..0380a3b 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4955,6 +4955,61 @@ qemuBuildMemoryDimmBackendStr(virDomainMemoryDefPtr mem,
}
+static int
+qemuBuildMemoryDeviceAddr(virBuffer *buf,
+ virDomainDefPtr def,
+ virDomainMemoryDefPtr mem)
+{
+ ssize_t i;
+
+ if (mem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
+ return 0;
+
+ if (mem->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("only 'dimm' addresses are supported for the "
+ "pc-dimm device"));
+ return -1;
+ }
+
+ if (mem->info.addr.dimm.slot >= def->mem.memory_slots) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("memory device slot '%u' exceeds slots count '%u'"),
+ mem->info.addr.dimm.slot, def->mem.memory_slots);
+ return -1;
+ }
+
+ for (i = 0; i < def->nmems; i++) {
+ virDomainMemoryDefPtr tmp = def->mems[i];
+
+ if (tmp == mem ||
+ tmp->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM)
+ continue;
+
+ if (mem->info.addr.dimm.slot == tmp->info.addr.dimm.slot) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("memory device slot '%u' already been"
+ " used by other memory device"),
+ mem->info.addr.dimm.slot);
+ return -1;
+ }
+
+ if (mem->info.addr.dimm.base != 0 && tmp->info.addr.dimm.base != 0 &&
+ mem->info.addr.dimm.base == tmp->info.addr.dimm.base) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("memory device base '0x%llx' already been"
+ " used by other memory device"),
+ mem->info.addr.dimm.base);
+ return -1;
+ }
+ }
+
+ virBufferAsprintf(buf, ",slot=%d", mem->info.addr.dimm.slot);
+ virBufferAsprintf(buf, ",addr=%llu", mem->info.addr.dimm.base);
+
+ return 0;
+}
+
char *
qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem,
virDomainDefPtr def,
@@ -4976,29 +5031,11 @@ qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem,
return NULL;
}
- if (mem->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM &&
- mem->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("only 'dimm' addresses are supported for the "
- "pc-dimm device"));
- return NULL;
- }
-
- if (mem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM &&
- mem->info.addr.dimm.slot >= def->mem.memory_slots) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("memory device slot '%u' exceeds slots count '%u'"),
- mem->info.addr.dimm.slot, def->mem.memory_slots);
- return NULL;
- }
-
virBufferAsprintf(&buf, "pc-dimm,node=%d,memdev=mem%s,id=%s",
mem->targetNode, mem->info.alias, mem->info.alias);
- if (mem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM) {
- virBufferAsprintf(&buf, ",slot=%d", mem->info.addr.dimm.slot);
- virBufferAsprintf(&buf, ",addr=%llu", mem->info.addr.dimm.base);
- }
+ if (qemuBuildMemoryDeviceAddr(&buf, def, mem) < 0)
+ return NULL;
break;
--
1.8.3.1
9 years, 5 months
[libvirt] [PATCH] maint: document use of zanata for translations
by Eric Blake
Based on recent list questions on how to contribute a translation fix.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Should be safe for freeze, but as I have never contributed a
translation fix, I'll wait for review.
HACKING | 19 ++++++++++++-------
docs/hacking.html.in | 7 +++++++
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/HACKING b/HACKING
index fbe838b..e308568 100644
--- a/HACKING
+++ b/HACKING
@@ -18,7 +18,12 @@ listen to feedback.
and is browsable along with other libvirt-related repositories (e.g.
libvirt-python) online <http://libvirt.org/git/>.
-(3) Post patches in unified diff format, with git rename detection enabled. You
+(3) Patches to translations are maintained via the zanata project
+<https://fedora.zanata.org/>. If you want to fix a translation in a .po file,
+join the appropriate language team. The libvirt release process automatically
+pulls the latest version of each translation file from zanata.
+
+(4) Post patches in unified diff format, with git rename detection enabled. You
need a one-time setup of:
git config diff.renames true
@@ -70,7 +75,7 @@ the correct version if needed though).
-(4) In your commit message, make the summary line reasonably short (60 characters
+(5) In your commit message, make the summary line reasonably short (60 characters
is typical), followed by a blank line, followed by any longer description of
why your patch makes sense. If the patch fixes a regression, and you know what
commit introduced the problem, mentioning that is useful. If the patch
@@ -82,7 +87,7 @@ is up to you if you want to include or omit them in the commit message.
-(5) Split large changes into a series of smaller patches, self-contained if
+(6) Split large changes into a series of smaller patches, self-contained if
possible, with an explanation of each patch and an explanation of how the
sequence of patches fits together. Moreover, please keep in mind that it's
required to be able to compile cleanly (*including* "make check" and "make
@@ -93,10 +98,10 @@ things).
-(6) Make sure your patches apply against libvirt GIT. Developers only follow GIT
+(7) Make sure your patches apply against libvirt GIT. Developers only follow GIT
and don't care much about released versions.
-(7) Run the automated tests on your code before submitting any changes. In
+(8) Run the automated tests on your code before submitting any changes. In
particular, configure with compile warnings set to -Werror. This is done
automatically for a git checkout; from a tarball, use:
@@ -149,7 +154,7 @@ various tests under gdb or Valgrind.
-(8) The Valgrind test should produce similar output to "make check". If the output
+(9) The Valgrind test should produce similar output to "make check". If the output
has traces within libvirt API's, then investigation is required in order to
determine the cause of the issue. Output such as the following indicates some
sort of leak:
@@ -225,7 +230,7 @@ to "tests/.valgrind.supp" in order to suppress the warning:
-(9) Update tests and/or documentation, particularly if you are adding a new
+(10) Update tests and/or documentation, particularly if you are adding a new
feature or changing the output of a program.
diff --git a/docs/hacking.html.in b/docs/hacking.html.in
index 408ea50..5cd23a2 100644
--- a/docs/hacking.html.in
+++ b/docs/hacking.html.in
@@ -16,6 +16,13 @@
along with other libvirt-related repositories
(e.g. libvirt-python) <a href="http://libvirt.org/git/">online</a>.</li>
+ <li>Patches to translations are maintained via
+ the <a href="https://fedora.zanata.org/">zanata project</a>.
+ If you want to fix a translation in a .po file, join the
+ appropriate language team. The libvirt release process
+ automatically pulls the latest version of each translation
+ file from zanata.</li>
+
<li><p>Post patches in unified diff format, with git rename
detection enabled. You need a one-time setup of:</p>
<pre>
--
2.1.0
9 years, 5 months
[libvirt] Canging bridge names on live migration
by seitan
Hello,
i wonder, if there's a possibility to change a name of a shared interface in
virtual machine config, while doing migration.
The problem is:
hypervisor1 (source) uses shared interface name "br0".
hypervisor2 (target) uses shared interface name "br500".
Live migration fails, because target hypervisor does not have "br0" interface.
Thank you
9 years, 5 months
[libvirt] [libvirt-php][PATCH] libvirt_connect_get_all_domain_stats: Add forgotten breaks
by Michal Privoznik
Unfortunately, during review I haven't spotted the obvious. There's
missing break in each switch() case which will definitely produce a
segmentation fault as it causes strdup() to be called on non-string
types too. Sorry for the noise.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Pushed under trivial rule.
src/libvirt-php.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index eb42994..698ab0f 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -2467,18 +2467,25 @@ PHP_FUNCTION(libvirt_connect_get_all_domain_stats)
switch (params.type) {
case VIR_TYPED_PARAM_INT:
add_assoc_long(arr2, params.field, params.value.i);
+ break;
case VIR_TYPED_PARAM_UINT:
add_assoc_long(arr2, params.field, params.value.ui);
+ break;
case VIR_TYPED_PARAM_LLONG:
add_assoc_long(arr2, params.field, params.value.l);
+ break;
case VIR_TYPED_PARAM_ULLONG:
add_assoc_long(arr2, params.field, params.value.ul);
+ break;
case VIR_TYPED_PARAM_DOUBLE:
add_assoc_double(arr2, params.field, params.value.d);
+ break;
case VIR_TYPED_PARAM_BOOLEAN:
add_assoc_bool(arr2, params.field, params.value.b);
+ break;
case VIR_TYPED_PARAM_STRING:
add_assoc_string_ex(arr2, params.field, strlen(params.field)+1, params.value.s, strlen(params.value.s)+1);
+ break;
}
}
name = virDomainGetName(retstats[i]->dom);
--
2.3.6
9 years, 5 months
Re: [libvirt] [RFC] libvirt support multi-thread compression for live migration
by Eric Blake
[correcting list address: libvirt-list, not libver-list]
On 06/02/2015 05:58 AM, Feng, Shaohe wrote:
> Hi folks:
> I'd like to request some comments on enabling multi-thread compression in libvirt.
>
> Currently, qemu upstream has supported multi-thread compression for live migration.
> $ git log 263170e~1..362ba4e -oneline
> This can preserve bandwidth and speed up the live migration process, so this is an import
> feature we need to enable so for other high level such as openstack will be benefit.
>
> We plan to add feature of multi-thread compression and actually the patch is working in process.
>
> Now some things need for comments.
>
> 1. Expose new set/get multi-thread compression parameters API for live migration.
> Now qemu only supports zlib compression. Maybe LZ4 and gzip will be supported later.
> but there are 3 parameters needed by qemu currently.
> "compress-level": compression level, default is 1. For zlib compression, it is from 0-9, 0 means use default level, 9 means high compressed.
> "compress-threads": compression thread count for multi-thread migration, default is 8 in qemu.
> "decompress-threads": decompression thread count for multi-thread migration, default is 2 in qemu
>
> So in libvirt we will expose the public symbols as follow, we only 3 parameters,
> missing compression method(zlib, LZ4 and gzip) parameters, for qemu do not support it at present.
> index d851225..103b3b9 100644
> --- a/include/libvirt/libvirt-domain.h
> +++ b/include/libvirt/libvirt-domain.h
> @@ -798,6 +798,17 @@ int virDomainMigrateGetMaxSpeed(virDomainPtr domain,
> unsigned long *bandwidth,
> unsigned int flags);
>
> +int virdomainMigrateSetParameters(virDomainPtr domain,
> + int level,
> + int threads,
> + int dthreads,
> + int flags)
> +int virdomainMigrateGetParameters(virDomainPtr domain,
> + int *level,
> + int *threads,
> + int *dthreads,
> + int flags)
> +
I'd rather we used virTypedParameters, to make it easier to use the same
API to pass ALL future possible tuning parameters, rather than just
hard-coding to only the parameters of this one feature.
>
> For virdomainMigrateSetParameters, if specifying a negative value to level, threads, and dthreads parameters, such as -1,
> means do not set the parameters.
> The underlying code will not pass the corresponding parameters to qemu monitor.
> Such as threads and dthreads is -1, then pass the following json streaming to qemu.
> { "execute": "migrate-set-parameters" , "arguments": { "compress-level": 1 } }
>
> The virsh will expose the two commands:
> # virsh migrate-setparameters <domain> [--level level] [--threads threads] [--dthreads dthread]
> # virsh migrate-getparameters <domain>
>
> 2. How to enable multi-thread compression in application interface?
> There is not a special interface for setting migration capabilities.
> But we can set the capabilities when execute an virsh command as following:
> $ migrate --live] [--offline] [--p2p] [--direct] [--tunnelled] [--persistent] [--undefinesource] [--suspend] [--copy-storage-all] [--copy-storage-inc] [--change-protection] [--unsafe] [--verbose] [--compressed] [--abort-on-error] <domain> <desturi> [<migrateuri>] [<graphicsuri>] [<listen-address>] [<dname>] [--timeout <number>] [--xml <string>]
>
> There is already a "compressed" option, here "compressed" means "xbzrle" not "multi- compressed".
> can I rename the "compressed" to "xbzrle"?
If we think that it is worth always turning on both compression styles
simultaneously, then reuse the bit. Otherwise, we need a different bit,
and users can choose which (or both) of the two compression styles as
desired.
> so we add another option for multi-thread compression, which is better option name? "-multi- compressed" ?
> Any way this is confuse to user. We need to distinguish<http://dict.youdao.com/w/distinguish/> these two.
>
>
> So I wonder should we expose new API to enable the migrate multi-thread compress.
> +int virdomainMigrateEnableMultiThreadCompress (virDomainPtr domain, int flags)
> It will pass the following command to qemu monitor.
> { "execute": "migrate-set-capabilities" , "arguments": { "capabilities": [ { "capability": " compress", "state": true } ] } }
>
> NOTE: Now, multiple thread compression can co-work with xbzrle. When xbzrle is on, multiple thread compression will only work at the first round of RAM data sync.
> Qemu, $ git show 98f1138902195bd9ab8a753d0ee2cf2a0a88b6e8
> if compress and xbzrle are both on, compress only takes effect in the ram bulk stage, after that, it will be disabled and only xbzrle takes effect, this can help to minimize migration traffic.
>
> 3. Migration between different livirt/qemu version
> We can support to expose 2 new API to set/get migrate capabilities.
> + virdomainMigrateSetCapabilities
> + virdomainMigrateGetCapabilities
> And we can suggest the user application to probe the capabilities before execute live migration in our doc.
> This need discussion is it necessary support these two in libvirt?
>
> Without the above GetCapabilities API, user application can probe multi-thread compress capabilities by virdomainMigrateGetParameters.
>
> Or
> return error directly when user application execute live migration with multi-thread flag specifying, but do not any Capabilities probe.
>
>
> INFO: qmeu command
> {"execute": "query-migrate-capabilities"}
> {"return": [{"state": false, "capability": "xbzrle"}, {"state": false, "capability": "rdma-pin-all"}, {"state": false, "capability": "auto-converge"}, {"state": false, "capability": "zero-blocks"}, {"state": false, "capability": "compress"}]}
>
>
>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
9 years, 5 months
[libvirt] [PATCH v2 00/22] Add support for migration events
by Jiri Denemark
QEMU will soon (patches are available on qemu-devel) get support for
migration events which will finally allow us to get rid of polling
query-migrate every 50ms. However, we first need to be able to wait for
all events related to migration (migration status changes, block job
events, async abort requests) at once. This series prepares the
infrastructure and uses it to switch all polling loops in migration code
to pthread_cond_wait.
https://bugzilla.redhat.com/show_bug.cgi?id=1212077
Version 2 (see individual patches for details):
- rewritten using per-domain condition variable
- enahnced to fully support the migration events
Jiri Denemark (22):
conf: Introduce per-domain condition variable
qemu: Introduce qemuBlockJobUpdate
qemu: Properly report failed migration
qemu: Use domain condition for synchronous block jobs
qemu: Don't mess with disk->mirrorState
Pass domain object to private data formatter/parser
qemu: Make qemuMigrationCancelDriveMirror usable without async job
qemu: Refactor qemuMonitorBlockJobInfo
qemu: Cancel disk mirrors after libvirtd restart
qemu: Use domain condition for asyncAbort
qemu_monitor: Wire up SPICE_MIGRATE_COMPLETED event
qemu: Do not poll for spice migration status
qemu: Refactor qemuDomainGetJob{Info,Stats}
qemu: Refactor qemuMigrationUpdateJobStatus
qemu: Don't pass redundant job name around
qemu: Refactor qemuMigrationWaitForCompletion
qemu_monitor: Wire up MIGRATION event
qemu: Update migration state according to MIGRATION event
qemu: Work around weired migration status changes
qemuDomainGetJobStatsInternal: Support migration events
qemu: Wait for migration events on domain condition
qemu: cancel drive mirrors when p2p connection breaks
po/POTFILES.in | 1 -
src/conf/domain_conf.c | 51 ++-
src/conf/domain_conf.h | 12 +-
src/libvirt_private.syms | 6 +
src/libxl/libxl_domain.c | 10 +-
src/lxc/lxc_domain.c | 12 +-
src/qemu/qemu_blockjob.c | 175 +++-------
src/qemu/qemu_blockjob.h | 15 +-
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_domain.c | 78 +++--
src/qemu/qemu_domain.h | 7 +-
src/qemu/qemu_driver.c | 201 +++++++-----
src/qemu/qemu_migration.c | 749 ++++++++++++++++++++++++++++---------------
src/qemu/qemu_migration.h | 8 +
src/qemu/qemu_monitor.c | 73 ++++-
src/qemu/qemu_monitor.h | 33 +-
src/qemu/qemu_monitor_json.c | 152 ++++-----
src/qemu/qemu_monitor_json.h | 7 +-
src/qemu/qemu_process.c | 92 +++++-
tests/qemumonitorjsontest.c | 40 ---
21 files changed, 1032 insertions(+), 693 deletions(-)
--
2.4.1
9 years, 5 months
[libvirt] [PATCH] virNumaSetPagePoolSize: Produce friendlier error message
by Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=1224587
The function takes two important arguments (among many others): @node
and @page_size. From these two a path under /sys is constructed. The
path is then used to read and write the desired size of huge pages
pool. However, if the path does not exists due to either @node or
@page_size having nonexistent value (e.g. there's no such NUMA node or
no page size like -2), an cryptic error message is produced:
virsh # allocpages --pagesize 2049 --pagecount 8 --cellno -2
error: Failed to open file '/sys/devices/system/node/node-2/hugepages/hugepages-2049kB/nr_hugepages': No such file or directory
Add two more checks to catch this and therefore produce much more
friendlier error messages.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/util/virnuma.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index 669192a..5807d8f 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -849,9 +849,27 @@ virNumaSetPagePoolSize(int node,
goto cleanup;
}
+ if (node != -1 && !virNumaNodeIsAvailable(node)) {
+ virReportError(VIR_ERR_OPERATION_FAILED,
+ _("NUMA node %d is not available"),
+ node);
+ goto cleanup;
+ }
+
if (virNumaGetHugePageInfoPath(&nr_path, node, page_size, "nr_hugepages") < 0)
goto cleanup;
+ if (!virFileExists(nr_path)) {
+ /* Strictly speaking, @nr_path contains both NUMA node and page size.
+ * So if it doesn't exist it can be due to any of those two is wrong.
+ * However, the existence of the node was checked a few lines above, so
+ * it can be only page size here. */
+ virReportError(VIR_ERR_OPERATION_FAILED,
+ _("page size %u not available"),
+ page_size);
+ goto cleanup;
+ }
+
/* Firstly check, if there's anything for us to do */
if (virFileReadAll(nr_path, 1024, &nr_buf) < 0)
goto cleanup;
--
2.3.6
9 years, 5 months
[libvirt] [PATCH v1] update snapshot api
by Vasiliy Tolstov
* add constants from libvirt to snapshots api
* add flags to snapshot functions
Signed-off-by: Vasiliy Tolstov <v.tolstov(a)selfip.ru>
---
src/libvirt-php.c | 87 ++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 61 insertions(+), 26 deletions(-)
diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index 0adc4be..e9b9657 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -1228,34 +1228,58 @@ PHP_MINIT_FUNCTION(libvirt)
REGISTER_LONG_CONSTANT("VIR_DOMAIN_CRASHED", 6, CONST_CS | CONST_PERSISTENT);
/* Volume constants */
- REGISTER_LONG_CONSTANT("VIR_STORAGE_VOL_RESIZE_ALLOCATE", 1, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VIR_STORAGE_VOL_RESIZE_DELTA", 2, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VIR_STORAGE_VOL_RESIZE_SHRINK", 4, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_STORAGE_VOL_RESIZE_ALLOCATE", 1, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_STORAGE_VOL_RESIZE_DELTA", 2, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_STORAGE_VOL_RESIZE_SHRINK", 4, CONST_CS | CONST_PERSISTENT);
/* Domain vCPU flags */
REGISTER_LONG_CONSTANT("VIR_DOMAIN_VCPU_CONFIG", VIR_DOMAIN_VCPU_CONFIG, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("VIR_DOMAIN_VCPU_CURRENT", VIR_DOMAIN_VCPU_CURRENT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("VIR_DOMAIN_VCPU_LIVE", VIR_DOMAIN_VCPU_LIVE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("VIR_DOMAIN_VCPU_MAXIMUM", VIR_DOMAIN_VCPU_MAXIMUM, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VIR_DOMAIN_VCPU_GUEST", VIR_DOMAIN_VCPU_GUEST, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_DOMAIN_VCPU_GUEST", VIR_DOMAIN_VCPU_GUEST, CONST_CS | CONST_PERSISTENT);
#if LIBVIR_VERSION_NUMBER>=8000
/* Domain snapshot constants */
REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_DELETE_CHILDREN", VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_DELETE_METADATA_ONLY", VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_DELETE_CHILDREN_ONLY", VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_CREATE_REDEFINE", VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_CREATE_CURRENT", VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_CREATE_NO_METADATA", VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_CREATE_HALT", VIR_DOMAIN_SNAPSHOT_CREATE_HALT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_CREATE_DISK_ONLY", VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_CREATE_REUSE_EXT", VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_CREATE_QUIESCE", VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_CREATE_ATOMIC", VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_CREATE_LIVE", VIR_DOMAIN_SNAPSHOT_CREATE_LIVE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_LIST_DESCENDANTS", VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_LIST_ROOTS", VIR_DOMAIN_SNAPSHOT_LIST_ROOTS, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_LIST_METADATA", VIR_DOMAIN_SNAPSHOT_LIST_METADATA, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_LIST_LEAVES", VIR_DOMAIN_SNAPSHOT_LIST_LEAVES, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_LIST_NO_LEAVES", VIR_DOMAIN_SNAPSHOT_LIST_NO_LEAVES, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_LIST_NO_METADATA", VIR_DOMAIN_SNAPSHOT_LIST_NO_METADATA, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_LIST_INACTIVE", VIR_DOMAIN_SNAPSHOT_LIST_INACTIVE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_LIST_ACTIVE", VIR_DOMAIN_SNAPSHOT_LIST_ACTIVE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_LIST_DISK_ONLY", VIR_DOMAIN_SNAPSHOT_LIST_DISK_ONLY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_LIST_INTERNAL", VIR_DOMAIN_SNAPSHOT_LIST_INTERNAL, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_LIST_EXTERNAL", VIR_DOMAIN_SNAPSHOT_LIST_EXTERNAL, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_REVERT_RUNNING", VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_REVERT_PAUSED", VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_REVERT_FORCE", VIR_DOMAIN_SNAPSHOT_REVERT_FORCE, CONST_CS | CONST_PERSISTENT);
#endif
/* Memory constants */
REGISTER_LONG_CONSTANT("VIR_MEMORY_VIRTUAL", 1, CONST_CS | CONST_PERSISTENT);
/* Version checking constants */
- REGISTER_LONG_CONSTANT("VIR_VERSION_BINDING", VIR_VERSION_BINDING, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VIR_VERSION_LIBVIRT", VIR_VERSION_LIBVIRT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_VERSION_BINDING", VIR_VERSION_BINDING, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_VERSION_LIBVIRT", VIR_VERSION_LIBVIRT, CONST_CS | CONST_PERSISTENT);
/* Network constants */
REGISTER_LONG_CONSTANT("VIR_NETWORKS_ACTIVE", VIR_NETWORKS_ACTIVE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VIR_NETWORKS_INACTIVE", VIR_NETWORKS_INACTIVE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VIR_NETWORKS_ALL", VIR_NETWORKS_ACTIVE |
- VIR_NETWORKS_INACTIVE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_NETWORKS_INACTIVE", VIR_NETWORKS_INACTIVE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_NETWORKS_ALL", VIR_NETWORKS_ACTIVE | VIR_NETWORKS_INACTIVE, CONST_CS | CONST_PERSISTENT);
/* Credential constants */
REGISTER_LONG_CONSTANT("VIR_CRED_USERNAME", 1, CONST_CS | CONST_PERSISTENT);
@@ -6394,17 +6418,19 @@ PHP_FUNCTION(libvirt_domain_get_job_info)
Since version: 0.4.1(-2)
Description: Function is used to get the information whether domain has the current snapshot
Arguments: @res [resource]: libvirt domain resource
+ @flags [int]
Returns: TRUE is domain has the current snapshot, otherwise FALSE (you may need to check for error using libvirt_get_last_error())
*/
PHP_FUNCTION(libvirt_domain_has_current_snapshot)
{
php_libvirt_domain *domain=NULL;
zval *zdomain;
+ long flags = 0;
int retval;
- GET_DOMAIN_FROM_ARGS("r",&zdomain);
+ GET_DOMAIN_FROM_ARGS("r|l",&zdomain, &flags);
- retval=virDomainHasCurrentSnapshot(domain->domain, 0);
+ retval=virDomainHasCurrentSnapshot(domain->domain, flags);
if (retval <= 0) RETURN_FALSE;
RETURN_TRUE;
}
@@ -6415,6 +6441,7 @@ PHP_FUNCTION(libvirt_domain_has_current_snapshot)
Description: This functions is used to lookup for the snapshot by it's name
Arguments: @res [resource]: libvirt domain resource
@name [string]: name of the snapshot to get the resource
+ @flags [int]
Returns: domain snapshot resource
*/
PHP_FUNCTION(libvirt_domain_snapshot_lookup_by_name)
@@ -6423,13 +6450,14 @@ PHP_FUNCTION(libvirt_domain_snapshot_lookup_by_name)
zval *zdomain;
int name_len;
char *name=NULL;
+ long flags = 0;
php_libvirt_snapshot *res_snapshot;
virDomainSnapshotPtr snapshot = NULL;
- GET_DOMAIN_FROM_ARGS("rs",&zdomain,&name,&name_len);
+ GET_DOMAIN_FROM_ARGS("rs|l",&zdomain,&name,&name_len, &flags);
if ( (name == NULL) || (name_len<1)) RETURN_FALSE;
- snapshot=virDomainSnapshotLookupByName(domain->domain, name, 0);
+ snapshot=virDomainSnapshotLookupByName(domain->domain, name, flags);
if (snapshot==NULL) RETURN_FALSE;
res_snapshot = (php_libvirt_snapshot *)emalloc(sizeof(php_libvirt_snapshot));
@@ -6446,6 +6474,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_lookup_by_name)
Since version: 0.4.1(-2)
Description: This function creates the domain snapshot for the domain identified by it's resource
Arguments: @res [resource]: libvirt domain resource
+ @flags [int]
Returns: domain snapshot resource
*/
PHP_FUNCTION(libvirt_domain_snapshot_create)
@@ -6453,11 +6482,12 @@ PHP_FUNCTION(libvirt_domain_snapshot_create)
php_libvirt_domain *domain=NULL;
php_libvirt_snapshot *res_snapshot;
zval *zdomain;
+ long flags = 0;
virDomainSnapshotPtr snapshot = NULL;
- GET_DOMAIN_FROM_ARGS("r",&zdomain);
+ GET_DOMAIN_FROM_ARGS("r|l",&zdomain, &flags);
- snapshot=virDomainSnapshotCreateXML(domain->domain, "<domainsnapshot/>", 0);
+ snapshot=virDomainSnapshotCreateXML(domain->domain, "<domainsnapshot/>", flags);
DPRINTF("%s: virDomainSnapshotCreateXML(%p, <xml>) returned %p\n", PHPFUNC, domain->domain, snapshot);
if (snapshot == NULL) RETURN_FALSE;
@@ -6475,6 +6505,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_create)
Since version: 0.4.1(-2)
Description: Function is used to get the XML description of the snapshot identified by it's resource
Arguments: @res [resource]: libvirt snapshot resource
+ @flags [int]
Returns: XML description string for the snapshot
*/
PHP_FUNCTION(libvirt_domain_snapshot_get_xml)
@@ -6482,11 +6513,12 @@ PHP_FUNCTION(libvirt_domain_snapshot_get_xml)
char *xml;
char *xml_out;
zval *zsnapshot;
+ long flags = 0;
php_libvirt_snapshot *snapshot;
- GET_SNAPSHOT_FROM_ARGS("r",&zsnapshot);
+ GET_SNAPSHOT_FROM_ARGS("r|l",&zsnapshot, &flags);
- xml = virDomainSnapshotGetXMLDesc(snapshot->snapshot, 0);
+ xml = virDomainSnapshotGetXMLDesc(snapshot->snapshot, flags);
if (xml==NULL) RETURN_FALSE;
RECREATE_STRING_WITH_E(xml_out,xml);
@@ -6499,19 +6531,21 @@ PHP_FUNCTION(libvirt_domain_snapshot_get_xml)
Since version: 0.4.1(-2)
Description: Function is used to revert the domain state to the state identified by the snapshot
Arguments: @res [resource]: libvirt snapshot resource
+ @flags [int]
Returns: TRUE on success, FALSE on error
*/
PHP_FUNCTION(libvirt_domain_snapshot_revert)
{
zval *zsnapshot;
php_libvirt_snapshot *snapshot;
- int ret;
+ long flags = 0;
+ int retval;
- GET_SNAPSHOT_FROM_ARGS("r",&zsnapshot);
+ GET_SNAPSHOT_FROM_ARGS("r|l",&zsnapshot, &flags);
- ret = virDomainRevertToSnapshot(snapshot->snapshot, 0);
- DPRINTF("%s: virDomainRevertToSnapshot(%p, 0) returned %d\n", PHPFUNC, snapshot->snapshot, ret);
- if (ret == -1) RETURN_FALSE;
+ retval = virDomainRevertToSnapshot(snapshot->snapshot, flags);
+ DPRINTF("%s: virDomainRevertToSnapshot(%p, 0) returned %d\n", PHPFUNC, snapshot->snapshot, retval);
+ if (retval == -1) RETURN_FALSE;
RETURN_TRUE;
}
@@ -6543,6 +6577,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_delete)
Since version: 0.4.1(-2)
Description: Function is used to list domain snapshots for the domain specified by it's resource
Arguments: @res [resource]: libvirt domain resource
+ @flags [int]
Returns: libvirt domain snapshot names array
*/
PHP_FUNCTION(libvirt_list_domain_snapshots)
@@ -6551,17 +6586,18 @@ PHP_FUNCTION(libvirt_list_domain_snapshots)
zval *zdomain;
int count=-1;
int expectedcount=-1;
+ long flags = 0;
char **names;
int i;
- GET_DOMAIN_FROM_ARGS("r",&zdomain);
+ GET_DOMAIN_FROM_ARGS("r|l",&zdomain, &flags);
- expectedcount=virDomainSnapshotNum(domain->domain, 0);
+ expectedcount=virDomainSnapshotNum(domain->domain, flags);
DPRINTF("%s: virDomainSnapshotNum(%p, 0) returned %d\n", PHPFUNC, domain->domain, expectedcount);
if (expectedcount != -1 ) {
names=(char **)emalloc( expectedcount * sizeof(char *) );
- count=virDomainSnapshotListNames(domain->domain, names, expectedcount, 0);
+ count=virDomainSnapshotListNames(domain->domain, names, expectedcount, flags);
}
if ((count != expectedcount) || (count<0)) {
@@ -8863,4 +8899,3 @@ PHP_FUNCTION(libvirt_logfile_set)
RETURN_TRUE;
}
#endif
-
--
2.3.3
9 years, 5 months