[libvirt] [PATCH 1/4] python: add python binding for virDomainGetBlkioParameters
by Hu Tao
---
python/libvirt-override-api.xml | 6 +-
python/libvirt-override.c | 79 +++++++++++++++++++++++++++++++++++++-
2 files changed, 79 insertions(+), 6 deletions(-)
diff --git a/python/libvirt-override-api.xml b/python/libvirt-override-api.xml
index a8929b1..00f8e6a 100644
--- a/python/libvirt-override-api.xml
+++ b/python/libvirt-override-api.xml
@@ -208,10 +208,10 @@
<arg name='params' type='virBlkioParameterPtr' info='pointer to blkio tunable objects'/>
</function>
<function name='virDomainGetBlkioParameters' file='python'>
- <info>Get the blkio parameters, the @params array will be filled with the values.</info>
- <return type='int' info='-1 in case of error, 0 in case of success.'/>
+ <info>Get the blkio parameters</info>
+ <return type='virSchedParameterPtr' info='None in case of error, returns a dictionary of params'/>
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
- <arg name='params' type='virBlkioParameterPtr' info='pointer to blkio tunable objects'/>
+ <arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
</function>
<function name='virDomainSetMemoryParameters' file='python'>
<info>Change the memory tunables</info>
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 70e0238..beb0969 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -572,11 +572,84 @@ libvirt_virDomainSetBlkioParameters(PyObject *self ATTRIBUTE_UNUSED,
return VIR_PY_INT_FAIL;
}
-/* FIXME: This is a place holder for the implementation. */
static PyObject *
libvirt_virDomainGetBlkioParameters(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args ATTRIBUTE_UNUSED) {
- return VIR_PY_INT_FAIL;
+ PyObject *args) {
+ virDomainPtr domain;
+ PyObject *pyobj_domain, *info;
+ int i_retval;
+ int nparams = 0, i;
+ unsigned int flags;
+ virTypedParameterPtr params;
+
+ if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainGetBlkioParameters",
+ &pyobj_domain, &flags))
+ return(NULL);
+ domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ i_retval = virDomainGetBlkioParameters(domain, NULL, &nparams, flags);
+ LIBVIRT_END_ALLOW_THREADS;
+
+ if (i_retval < 0)
+ return VIR_PY_NONE;
+
+ if ((params = malloc(sizeof(*params)*nparams)) == NULL)
+ return VIR_PY_NONE;
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ i_retval = virDomainGetBlkioParameters(domain, params, &nparams, flags);
+ LIBVIRT_END_ALLOW_THREADS;
+
+ if (i_retval < 0) {
+ free(params);
+ return VIR_PY_NONE;
+ }
+
+ /* convert to a Python tuple of long objects */
+ if ((info = PyDict_New()) == NULL) {
+ free(params);
+ return VIR_PY_NONE;
+ }
+ for (i = 0 ; i < nparams ; i++) {
+ PyObject *key, *val;
+
+ switch (params[i].type) {
+ case VIR_TYPED_PARAM_INT:
+ val = PyInt_FromLong((long)params[i].value.i);
+ break;
+
+ case VIR_TYPED_PARAM_UINT:
+ val = PyInt_FromLong((long)params[i].value.ui);
+ break;
+
+ case VIR_TYPED_PARAM_LLONG:
+ val = PyLong_FromLongLong((long long)params[i].value.l);
+ break;
+
+ case VIR_TYPED_PARAM_ULLONG:
+ val = PyLong_FromLongLong((long long)params[i].value.ul);
+ break;
+
+ case VIR_TYPED_PARAM_DOUBLE:
+ val = PyFloat_FromDouble((double)params[i].value.d);
+ break;
+
+ case VIR_TYPED_PARAM_BOOLEAN:
+ val = PyBool_FromLong((long)params[i].value.b);
+ break;
+
+ default:
+ free(params);
+ Py_DECREF(info);
+ return VIR_PY_NONE;
+ }
+
+ key = libvirt_constcharPtrWrap(params[i].field);
+ PyDict_SetItem(info, key, val);
+ }
+ free(params);
+ return(info);
}
/* FIXME: This is a place holder for the implementation. */
--
1.7.3.1
13 years, 4 months
[libvirt] [PATCH 00/19] Rollback migration when libvirtd restarts
by Jiri Denemark
This series is also available at
https://gitorious.org/~jirka/libvirt/jirka-staging/commits/migration-reco...
The series does several things:
- persists current job and its phase in status xml
- allows safe monitor commands to be run during migration/save/dump jobs
- implements recovery when libvirtd is restarted while a job is active
- consolidates some code and fixes bugs I found when working in the area
The series is not perfect and still needs some corner cases to be fixed but I
think it's better to send the series for review now and add small additional
fixes in the next version(s) instead of waiting for it to be perfect.
Jiri Denemark (19):
qemu: Separate job related data into a new object
qemu: Consolidate BeginJob{,WithDriver} into a single method
qemu: Consolidate {Enter,Exit}Monitor{,WithDriver}
qemu: Allow all query commands to be run during long jobs
qemu: Save job type in domain status XML
qemu: Recover from interrupted jobs
qemu: Add support for job phase
qemu: Consolidate qemuMigrationPrepare{Direct,Tunnel}
qemu: Implement migration job phases
qemu: Migration job on destination daemon
qemu: Migration job on source daemon
qemu: Recover from interrupted migration
qemu: Fix monitor unlocking in some error paths
qemu: Remove special case for virDomainGetBlockInfo
qemu: Remove special case for virDomainBlockStats
qemu: Remove special case for virDomainMigrateSetMaxSpeed
qemu: Remove special case for virDomainMigrateSetMaxDowntime
qemu: Remove special case for virDomainSuspend
qemu: Remove special case for virDomainAbortJob
src/libvirt.c | 11 +-
src/qemu/MIGRATION.txt | 55 +++
src/qemu/qemu_domain.c | 575 ++++++++++++++++++++++++-------
src/qemu/qemu_domain.h | 130 +++++--
src/qemu/qemu_driver.c | 467 +++++++++++++------------
src/qemu/qemu_hotplug.c | 50 ++--
src/qemu/qemu_migration.c | 849 +++++++++++++++++++++++----------------------
src/qemu/qemu_migration.h | 36 ++
src/qemu/qemu_process.c | 244 ++++++++++++-
9 files changed, 1569 insertions(+), 848 deletions(-)
create mode 100644 src/qemu/MIGRATION.txt
--
1.7.6
13 years, 4 months
[libvirt] [PATCH] virsh: fix memory leak in cmdVolPath code
by ajia@redhat.com
* tools/virsh.c: avoid memory leak in cmdVolPath.
* how to reproduce?
% dd if=/dev/zero of=/var/lib/libvirt/images/foo.img count=1 bs=10M
% virsh pool-refresh default
% valgrind -v --leak-check=full virsh vol-path --vol
/var/lib/libvirt/images/foo.img
* actual results:
Detected in valgrind run:
==16436== 32 bytes in 1 blocks are definitely lost in loss record 7 of 22
==16436== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==16436== by 0x386A314B3D: xdr_string (in /lib64/libc-2.12.so)
==16436== by 0x3DF8CD770D: xdr_remote_nonnull_string (remote_protocol.c:30)
==16436== by 0x3DF8CD7EC8: xdr_remote_storage_vol_get_path_ret
(remote_protocol.c:2952)
==16436== by 0x3DF8CDF161: virNetMessageDecodePayload (virnetmessage.c:286)
==16436== by 0x3DF8CDE9E5: virNetClientProgramCall
(virnetclientprogram.c:318)
==16436== by 0x3DF8CC28A2: call (remote_driver.c:3929)
==16436== by 0x3DF8CC8412: remoteStorageVolGetPath
(remote_client_bodies.h:5219)
==16436== by 0x3DF8C9BF14: virStorageVolGetPath (libvirt.c:11389)
==16436== by 0x418ECA: cmdVolPath (virsh.c:8754)
==16436== by 0x410CC2: vshCommandRun (virsh.c:12758)
==16436== by 0x41F286: main (virsh.c:14110)
==16436==
==16436== LEAK SUMMARY:
==16436== definitely lost: 32 bytes in 1 blocks
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
tools/virsh.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 841df61..d194a8b 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -9326,6 +9326,7 @@ cmdVolPath(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolPtr vol;
const char *name = NULL;
+ char * StorageVolPath;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
@@ -9334,7 +9335,13 @@ cmdVolPath(vshControl *ctl, const vshCmd *cmd)
return false;
}
- vshPrint(ctl, "%s\n", virStorageVolGetPath(vol));
+ if ((StorageVolPath = virStorageVolGetPath(vol)) == NULL) {
+ virStorageVolFree(vol);
+ return false;
+ }
+
+ vshPrint(ctl, "%s\n", StorageVolPath);
+ VIR_FREE(StorageVolPath);
virStorageVolFree(vol);
return true;
}
--
1.7.1
13 years, 4 months
[libvirt] Memory leak of the remoteDomainSet* functions
by Osier Yang
Hello, there
Per bug https://bugzilla.redhat.com/show_bug.cgi?id=725322, should
we change the remoteDomainSet* functions into "skipgen", and fix the
leaks like below? (NB, new VIR_FREE statements)
static int
remoteDomainSetBlkioParameters(virDomainPtr dom,
virTypedParameterPtr params,
int nparams,
unsigned int flags)
{
int rv = -1;
int i;
struct private_data *priv = dom->conn->privateData;
remote_domain_set_blkio_parameters_args args;
remote_domain_set_blkio_parameters_args args;
remoteDriverLock(priv);
make_nonnull_domain(&args.dom, dom);
args.flags = flags;
if (remoteSerializeTypedParameters(params,
nparams,
&args.params.params_val,
&args.params.params_len) < 0) {
for (i = 0; i < nparams; i++) {
VIR_FREE(args.params.params_val[i].field);
}
VIR_FREE(args.params.params_val);
xdr_free((xdrproc_t)xdr_remote_domain_set_blkio_parameters_args, (char
*)&args);
goto done;
}
if (call(dom->conn, priv, 0, REMOTE_PROC_DOMAIN_SET_BLKIO_PARAMETERS,
(xdrproc_t)xdr_remote_domain_set_blkio_parameters_args, (char *)&args,
(xdrproc_t)xdr_void, (char *)NULL) == -1) {
goto done;
}
rv = 0;
done:
if (args.params.params_val) {
for (i = 0; i < nparams; i++) {
VIR_FREE(args.params.params_val[i].field);
}
VIR_FREE(args.params.params_val);
}
remoteDriverUnlock(priv);
return rv;
}
Regards,
Osier
13 years, 4 months
[libvirt] [PATCH] qemu: Remove bogus codes in function getCompressionType
by Osier Yang
The error will never be reported, remove the codes, and also
improve the docs in qemu.conf to tell user the truth.
---
src/qemu/qemu.conf | 4 ++++
src/qemu/qemu_driver.c | 16 +++++-----------
2 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 145062c..75d945b 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -199,6 +199,10 @@
# save_image_format is used when you use 'virsh save' at scheduled saving.
# dump_image_format is used when you use 'virsh dump' at emergency crashdump.
#
+# If the specified format is not valid (the valid formats are "raw", "lzop",
+# "gzip", "bzip2", and "xz"), or the compress program is not available, "raw"
+# will be used as the format silently without error or warning.
+#
# save_image_format = "raw"
# dump_image_format = "raw"
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b928004..48fc46a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2712,19 +2712,13 @@ getCompressionType(struct qemud_driver *driver)
*/
if (driver->dumpImageFormat) {
compress = qemudSaveCompressionTypeFromString(driver->dumpImageFormat);
- if (compress < 0) {
- qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
- _("Invalid dump image format specified in "
- "configuration file, using raw"));
+ /* Use "raw" as the format if the specified format is not valid,
+ * or the compress program is not available,
+ */
+ if (compress < 0)
return QEMUD_SAVE_FORMAT_RAW;
- }
- if (!qemudCompressProgramAvailable(compress)) {
- qemuReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("Compression program for dump image format "
- "in configuration file isn't available, "
- "using raw"));
+ if (!qemudCompressProgramAvailable(compress))
return QEMUD_SAVE_FORMAT_RAW;
- }
}
return compress;
}
--
1.7.6
13 years, 4 months
[libvirt] [PATCH] qemu: improve thread documentation
by Eric Blake
* src/qemu/THREADS.txt: Fix problems with typos, grammar, and
outdated examples.
---
Doc only, so pushing under the trivial rule.
src/qemu/THREADS.txt | 30 ++++++++++++++++--------------
1 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/src/qemu/THREADS.txt b/src/qemu/THREADS.txt
index 3a27a85..e73076c 100644
--- a/src/qemu/THREADS.txt
+++ b/src/qemu/THREADS.txt
@@ -6,7 +6,7 @@ the QEMU driver. The criteria for this model are:
- Objects must never be exclusively locked for any prolonged time
- Code which sleeps must be able to time out after suitable period
- - Must be safe against dispatch asynchronous events from monitor
+ - Must be safe against dispatch of asynchronous events from monitor
Basic locking primitives
@@ -19,7 +19,7 @@ There are a number of locks on various objects
This is the top level lock on the entire driver. Every API call in
the QEMU driver is blocked while this is held, though some internal
callbacks may still run asynchronously. This lock must never be held
- for anything which sleeps/waits (ie monitor commands)
+ for anything which sleeps/waits (i.e. monitor commands)
When obtaining the driver lock, under *NO* circumstances must
any lock be held on a virDomainObjPtr. This *WILL* result in
@@ -44,7 +44,7 @@ There are a number of locks on various objects
to have the driver locked when re-acquiring the dropped locked, since the
reference count prevents it being freed by another thread.
- This lock must not be held for anything which sleeps/waits (ie monitor
+ This lock must not be held for anything which sleeps/waits (i.e. monitor
commands).
@@ -80,7 +80,7 @@ There are a number of locks on various objects
whenever it hits a piece of code which may sleep/wait, and
re-acquire it after the sleep/wait. Whenever an asynchronous job
wants to talk to the monitor, it needs to acquire nested job (a
- special kind of normla job) to obtain exclusive access to the
+ special kind of normal job) to obtain exclusive access to the
monitor.
Since the virDomainObjPtr lock was dropped while waiting for the
@@ -139,7 +139,7 @@ To acquire the normal job condition
- Increments ref count on virDomainObjPtr
- Waits until the job is compatible with current async job or no
async job is running
- - Waits job.cond condition 'job.active != 0' using virDomainObjPtr
+ - Waits for job.cond condition 'job.active != 0' using virDomainObjPtr
mutex
- Rechecks if the job is still compatible and repeats waiting if it
isn't
@@ -150,7 +150,7 @@ To acquire the normal job condition
- Unlocks driver
- Waits until the job is compatible with current async job or no
async job is running
- - Waits job.cond condition 'job.active != 0' using virDomainObjPtr
+ - Waits for job.cond condition 'job.active != 0' using virDomainObjPtr
mutex
- Rechecks if the job is still compatible and repeats waiting if it
isn't
@@ -160,7 +160,7 @@ To acquire the normal job condition
- Locks virDomainObjPtr
NB: this variant is required in order to comply with lock ordering
- rules for virDomainObjPtr vs driver
+ rules for virDomainObjPtr vs. driver
qemuDomainObjEndJob()
@@ -175,7 +175,7 @@ To acquire the asynchronous job condition
qemuDomainObjBeginAsyncJob() (if driver is unlocked)
- Increments ref count on virDomainObjPtr
- Waits until no async job is running
- - Waits job.cond condition 'job.active != 0' using virDomainObjPtr
+ - Waits for job.cond condition 'job.active != 0' using virDomainObjPtr
mutex
- Rechecks if any async job was started while waiting on job.cond
and repeats waiting in that case
@@ -185,7 +185,7 @@ To acquire the asynchronous job condition
- Increments ref count on virDomainObjPtr
- Unlocks driver
- Waits until no async job is running
- - Waits job.cond condition 'job.active != 0' using virDomainObjPtr
+ - Waits for job.cond condition 'job.active != 0' using virDomainObjPtr
mutex
- Rechecks if any async job was started while waiting on job.cond
and repeats waiting in that case
@@ -271,7 +271,7 @@ Design patterns
- * Accessing something directly todo with a virDomainObjPtr
+ * Accessing something directly to do with a virDomainObjPtr
virDomainObjPtr obj;
@@ -285,7 +285,7 @@ Design patterns
- * Accessing something directly todo with a virDomainObjPtr and driver
+ * Accessing something directly to do with a virDomainObjPtr and driver
virDomainObjPtr obj;
@@ -299,11 +299,11 @@ Design patterns
- * Updating something directly todo with a virDomainObjPtr
+ * Updating something directly to do with a virDomainObjPtr
virDomainObjPtr obj;
- qemuDriverLockRO(driver);
+ qemuDriverLock(driver);
obj = virDomainFindByUUID(driver->domains, dom->uuid);
qemuDriverUnlock(driver);
@@ -324,7 +324,7 @@ Design patterns
virDomainObjPtr obj;
qemuDomainObjPrivatePtr priv;
- qemuDriverLockRO(driver);
+ qemuDriverLock(driver);
obj = virDomainFindByUUID(driver->domains, dom->uuid);
qemuDriverUnlock(driver);
@@ -333,6 +333,7 @@ Design patterns
...do prep work...
if (virDomainObjIsActive(vm)) {
+ /* using ignore_value is safe since vm is active */
ignore_value(qemuDomainObjEnterMonitor(obj));
qemuMonitorXXXX(priv->mon);
qemuDomainObjExitMonitor(obj);
@@ -360,6 +361,7 @@ Design patterns
...do prep work...
if (virDomainObjIsActive(vm)) {
+ /* using ignore_value is safe since vm is active */
ignore_value(qemuDomainObjEnterMonitorWithDriver(driver, obj));
qemuMonitorXXXX(priv->mon);
qemuDomainObjExitMonitorWithDriver(driver, obj);
--
1.7.4.4
13 years, 4 months
[libvirt] [PATCH] virsh: expose change-protection during migration
by Eric Blake
* tools/virsh.c (doMigrate): Add --change-protection flag.
* tools/virsh.pod (migrate): Document it.
---
As promised here:
https://www.redhat.com/archives/libvir-list/2011-July/msg01919.html
tools/virsh.c | 4 ++++
tools/virsh.pod | 9 +++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 113124f..34036f9 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -4830,6 +4830,8 @@ static const vshCmdOptDef opts_migrate[] = {
{"suspend", VSH_OT_BOOL, 0, N_("do not restart the domain on the destination host")},
{"copy-storage-all", VSH_OT_BOOL, 0, N_("migration with non-shared storage with full disk copy")},
{"copy-storage-inc", VSH_OT_BOOL, 0, N_("migration with non-shared storage with incremental copy (same base image shared between source and destination)")},
+ {"change-protection", VSH_OT_BOOL, 0,
+ N_("prevent any configuration changes to source until migration ends)")},
{"verbose", VSH_OT_BOOL, 0, N_("display the progress of migration")},
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
{"desturi", VSH_OT_DATA, VSH_OFLAG_REQ, N_("connection URI of the destination host as seen from the client(normal migration) or source(p2p migration)")},
@@ -4906,6 +4908,8 @@ doMigrate (void *opaque)
if (vshCommandOptBool (cmd, "copy-storage-inc"))
flags |= VIR_MIGRATE_NON_SHARED_INC;
+ if (vshCommandOptBool (cmd, "change-protection"))
+ flags |= VIR_MIGRATE_CHANGE_PROTECTION;
if (xmlfile &&
virFileReadAll(xmlfile, 8192, &xml) < 0)
diff --git a/tools/virsh.pod b/tools/virsh.pod
index e9aaa80..6c3c960 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -564,8 +564,9 @@ type attribute for the <domain> element of XML.
=item B<migrate> [I<--live>] [I<--direct>] [I<--p2p> [I<--tunnelled>]]
[I<--persistent>] [I<--undefinesource>] [I<--suspend>] [I<--copy-storage-all>]
-[I<--copy-storage-inc>] [I<--verbose>] I<domain-id> I<desturi> [I<migrateuri>]
-[I<dname>] [I<--timeout> B<seconds>] [I<--xml> B<file>]
+[I<--copy-storage-inc>] [I<--change-protection>] [I<--verbose>]
+I<domain-id> I<desturi> [I<migrateuri>] [I<dname>]
+[I<--timeout> B<seconds>] [I<--xml> B<file>]
Migrate domain to another host. Add I<--live> for live migration; I<--p2p>
for peer-2-peer migration; I<--direct> for direct migration; or I<--tunnelled>
@@ -575,6 +576,10 @@ and I<--suspend> leaves the domain paused on the destination host.
I<--copy-storage-all> indicates migration with non-shared storage with full
disk copy, I<--copy-storage-inc> indicates migration with non-shared storage
with incremental copy (same base image shared between source and destination).
+I<--change-protection> enforces that no incompatible configuration changes
+will be made to the domain while the migration is underway; this flag is
+implicitly enabled when supported by the hypervisor, but can be used to
+reject the migration if the hypervisor lacks change protection support.
I<--verbose> displays the progress of migration.
The I<desturi> is the connection URI of the destination host, and
--
1.7.4.4
13 years, 4 months
Re: [libvirt] [virt-tools-list] virt-manager/libvirt backwards compatibility problem?
by Cole Robinson
On 07/27/2011 12:28 PM, Whit Blauvelt wrote:
> Looks like my real problem may be not incorporating a Debian/Ubuntu patch
> before building 0.9.x, since netcat differs:
>
> https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/517478
>
Hmm, what was the error message you were getting? We've made efforts at
the libvirt level to have useful error reporting here, so that the cause
of failure is more obvious.
Also, I patched virt-manager a while ago to use a shell script to handle
both RH and debian 'nc' versions. Script is here:
http://git.fedorahosted.org/git?p=virt-manager.git;a=blob;f=src/virtManag...
Yeah, it's complete and utter crack, but this has been a constant
frustration for users, so maybe worth revisiting at the libvirt level
(and hey, launching nc over ssh is kinda crack to being with :) ).
Even if we solved this in a clean way by providing our own
/usr/libexec/libvirt_nc binary, we'd still probably have to play shell
script games over SSH to handle connecting to older libvirt (or what if
libvirt_nc was installed somewhere other than libexec?)
- Cole
13 years, 4 months
[libvirt] [PATCH] rpc: Fix memory leak in remoteDomainSet*Parameters functions
by Matthias Bolte
Add a new helper remoteFreeTypedParameters and teach the generator
to add it to the cleanup section.
https://bugzilla.redhat.com/show_bug.cgi?id=725322
---
src/remote/remote_driver.c | 22 +++++++++++++++++-----
src/rpc/gendispatch.pl | 5 +++++
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 0652e0d..e5bfa4b 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -1208,6 +1208,22 @@ done:
return rv;
}
+/* Helper to free typed parameters. */
+static void
+remoteFreeTypedParameters(remote_typed_param *args_params_val,
+ u_int args_params_len)
+{
+ u_int i;
+
+ if (args_params_val == NULL)
+ return;
+
+ for (i = 0; i < args_params_len; i++)
+ VIR_FREE(args_params_val[i].field);
+
+ VIR_FREE(args_params_val);
+}
+
/* Helper to serialize typed parameters. */
static int
remoteSerializeTypedParameters(virTypedParameterPtr params,
@@ -1264,11 +1280,7 @@ remoteSerializeTypedParameters(virTypedParameterPtr params,
rv = 0;
cleanup:
- if (val) {
- for (i = 0; i < nparams; i++)
- VIR_FREE(val[i].field);
- VIR_FREE(val);
- }
+ remoteFreeTypedParameters(val, nparams);
return rv;
}
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index ceeb1f5..0d344e8 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -979,6 +979,7 @@ elsif ($opt_k) {
my @args_check_list = ();
my @setters_list = ();
my @setters_list2 = ();
+ my @free_list = ();
my $priv_src = "conn";
my $priv_name = "privateData";
my $call_args = "&args";
@@ -1105,6 +1106,7 @@ elsif ($opt_k) {
" xdr_free((xdrproc_t)xdr_$call->{args}, (char *)&args);\n" .
" goto done;\n" .
" }");
+ push(@free_list, " remoteFreeTypedParameters(args.params.params_val, args.params.params_len);\n");
} elsif ($args_member =~ m/^((?:unsigned )?int) (\S+);\s*\/\*\s*call-by-reference\s*\*\//) {
my $type_name = "$1 *";
my $arg_name = $2;
@@ -1500,6 +1502,9 @@ elsif ($opt_k) {
print "\n";
print "done:\n";
+
+ print join("\n", @free_list);
+
print " remoteDriverUnlock(priv);\n";
print " return rv;\n";
print "}\n";
--
1.7.4.1
13 years, 4 months
[libvirt] Environmental Variables inside a container
by Devendra K. Modium
Hi All
I am trying to pass an environmental flag to the
LXC container when it is started.I found libvirt_lxc is
already doing it in lxc_container.c as shown below
static virCommandPtr lxcContainerBuildInitCmd(virDomainDefPtr vmDef)
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
virCommandPtr cmd;
virUUIDFormat(vmDef->uuid, uuidstr);
cmd = virCommandNew(vmDef->os.init);
virCommandAddEnvString(cmd, "PATH=/bin:/sbin");
virCommandAddEnvString(cmd, "TERM=linux-deva");
virCommandAddEnvPair(cmd, "LIBVIRT_LXC_UUID", uuidstr);
virCommandAddEnvPair(cmd, "LIBVIRT_LXC_NAME", vmDef->name);
return cmd;
}
But only
TERM flag is getting visible inside the container not remaining.
Does it depends on how /sbin/init is receiving them? Is /sbin/init
only recognizing TERM flag.
If so what is intention of sending remaining flags in current libvirt.
Please let me know if there is any elegant way to send environmental
variable to container.
Thanks for your time.
Regards
Devendra
13 years, 4 months