[libvirt] [PATCH 00/11] Replace virXXXFree calls with virObjectUnref
by John Ferlan
Based on some recent review comments and a bit of internal IRC, this
set of patches will change all the existing virXXXFree calls found in
daemon/* and src/* to be virObjectUnref instead and then add a rule to
inhibit usage unless the string/call is found in docs/*, tests/*, examples/*,
tools/*, cfg.mk, libvirt_public.syms, include/libvirt/libvirt-*.h, and
src/libvirt-*.c
Most of this was brute force to start with and adding the rule afterwards
caught a few oddball places.
The reason for not wanting to call a virXXXFree function is because it
will reset the last error, potentially clearing something and resulting
in a message "an error was encountered but the cause is unknown". There
were some places in the code which saved the last error, called the free
function, then restored the last error. Those have now been adjusted to
avoid that processing. Anything that required checking for a non NULL
pointer prior to calling the virXXXFree is now not necessary since the
virObjectUnref will check for NULL before continuing; whereas, the
virXXXFree functions didn't allow NULL.
If usage of the virXXXFree function is found during syntax-check, a message
such as the following will be displayed:
include/libvirt/libvirt-storage.h:256:int virStoragePoolFree (virStoragePoolPtr pool);
include/libvirt/libvirt-storage.h:336:int virStorageVolFree (virStorageVolPtr vol);
maint.mk: avoid using virXXXFree, use virObjectUnref instead
make: *** [sc_prohibit_virXXXFree] Error 1
John Ferlan (11):
rpc: Replace virXXXFree with virObjectUnref
Replace virDomainFree with virObjectUnref
Replace virNetworkFree with virObjectUnref
Replace virNodeDeviceFree with virObjectUnref
Replace virStorageVolFree with virObjectUnref
Replace virStoragePoolFree with virObjectUnref
Replace virStreamFree with virObjectUnref
Replace virSecretFree with virObjectUnref
Replace virNWFilterFree with virObjectUnref
Replace virInterfaceFree with virObjectUnref
Replace virDomainSnapshotFree with virObjectUnref
cfg.mk | 12 +++
daemon/remote.c | 168 ++++++++++++--------------------
daemon/stream.c | 2 +-
src/conf/domain_event.c | 4 +-
src/conf/network_conf.c | 6 +-
src/conf/network_event.c | 2 +-
src/conf/node_device_conf.c | 6 +-
src/conf/storage_conf.c | 6 +-
src/conf/virchrdev.c | 4 +-
src/esx/esx_driver.c | 2 +-
src/fdstream.c | 2 +-
src/hyperv/hyperv_driver.c | 2 +-
src/interface/interface_backend_netcf.c | 6 +-
src/interface/interface_backend_udev.c | 2 +-
src/libxl/libxl_conf.c | 7 +-
src/locking/sanlock_helper.c | 3 +-
src/lxc/lxc_driver.c | 8 +-
src/lxc/lxc_process.c | 8 +-
src/nwfilter/nwfilter_driver.c | 6 +-
src/qemu/qemu_command.c | 8 +-
src/qemu/qemu_driver.c | 4 +-
src/qemu/qemu_hotplug.c | 8 +-
src/remote/remote_driver.c | 76 +++++++--------
src/rpc/gendispatch.pl | 17 ++--
src/secret/secret_driver.c | 6 +-
src/storage/storage_backend.c | 4 +-
src/storage/storage_backend_fs.c | 4 +-
src/storage/storage_backend_rbd.c | 3 +-
src/storage/storage_driver.c | 20 +---
src/uml/uml_conf.c | 2 +-
src/vbox/vbox_common.c | 6 +-
src/xenconfig/xen_common.c | 2 +-
src/xenconfig/xen_sxpr.c | 2 +-
33 files changed, 155 insertions(+), 263 deletions(-)
--
1.9.3
9 years, 11 months
[libvirt] [PATCH] qemu: update disk chain in vm->newDef when block job compeleted
by weiwei li
A bug will be hitted with libvirt+qemu+kvm when doing follow steps:
1.initial status :vm = base+z(z is a snapshot)
2. call snapshotCreateXML( ): vm = base+z +z'
3. call blockRebase( ): vm = base+z''(z rebase to z')
4.(after rebasing work done) vm shutdown and then start
an error occured like this:
"unable to set user and group to '0:0' on '
/path/to/disk': No such file or directory
A second start may sucess.
The error message reported by virSecurityDACSetSecurityDiskLabel
when the disk chain is misused(that is base+z +z', after rebase,
but z' was deleted yet).virSecurityDACSetSecurityDiskLabel used
an old disk chain after rebasing.
In qemuProcessHandleBlockJob when rebase complete, the disk chain
in vm->def is updated but vm->newDef is not(when vm->newDef is not
null). In shutdown( actrully in qemuProcessStop ), if vm->newDef
is not null , vm->def will be replaced by vm->newDef, which
contains a wrong disk chain!!! Then the next start will failed with
above message.
To fix it, update disk chain in vm->newDef in qemuProcessHandleBlockJob.
Signed-off-by: Weiwei Li <nuonuoli(a)tencent.com>
---
src/qemu/qemu_process.c | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 24e5f0f..0491249 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1033,6 +1033,7 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon
ATTRIBUTE_UNUSED,
virDomainDiskDefPtr disk;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
virDomainDiskDefPtr persistDisk = NULL;
+ virDomainDiskDefPtr newDisk = NULL;
bool save = false;
virObjectLock(vm);
@@ -1101,6 +1102,32 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon
ATTRIBUTE_UNUSED,
disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN;
ignore_value(qemuDomainDetermineDiskChain(driver, vm, disk,
true, true));
+ /* Chang vm->newDef disk chain */
+ if (!persistDisk && vm->newDef){
+ int indx = virDomainDiskIndexByName(vm->newDef,
+ disk->dst,
+ false);
+ virStorageSourcePtr copy = NULL;
+
+ if (indx >=0){
+ newDisk = vm->newDef->disks[indx];
+ copy = virStorageSourceCopy(disk->src, false);
+ if (virStorageSourceInitChainElement(copy,
+ newDisk->src,
+ false) < 0) {
+ VIR_WARN("Unable to update newDef definition "
+ "on vm %s after block job",
+ vm->def->name);
+ virStorageSourceFree(copy);
+ copy = NULL;
+ newDisk = NULL;
+ }
+ }
+ if (copy){
+ virStorageSourceFree(newDisk->src);
+ newDisk->src = copy;
+ }
+ }
} else if (disk->mirror &&
(type == VIR_DOMAIN_BLOCK_JOB_TYPE_COPY ||
type == VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT)) {
--
1.7.1
9 years, 11 months
[libvirt] [PATCH] parallels: fix compilation of parallels_storage.c
by Dmitry Guryanov
virConnect.privateData is void *, so we can't access
fields of parallelsConn, pointer to which is stored in
virConnect.privateData. So replace all occurences of
conn->privateData->storageState with privconn->storageState.
Signed-off-by: Dmitry Guryanov <dguryanov(a)parallels.com>
---
src/parallels/parallels_storage.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/parallels/parallels_storage.c b/src/parallels/parallels_storage.c
index e1b6ea8..882cbd0 100644
--- a/src/parallels/parallels_storage.c
+++ b/src/parallels/parallels_storage.c
@@ -72,8 +72,8 @@ parallelsStorageClose(virConnectPtr conn)
{
parallelsConnPtr privconn = conn->privateData;
- virStorageDriverStatePtr storageState = conn->privateData->storageState;
- conn->privateData->storageState = NULL;
+ virStorageDriverStatePtr storageState = privconn->storageState;
+ privconn->storageState = NULL;
parallelsStorageLock(storageState);
virStoragePoolObjListFree(&privconn->pools);
@@ -189,7 +189,7 @@ parallelsPoolCreateByPath(virConnectPtr conn, const char *path)
if (!(pool = virStoragePoolObjAssignDef(pools, def)))
goto error;
- if (virStoragePoolObjSaveDef(conn->privateData->storageState, pool, def) < 0) {
+ if (virStoragePoolObjSaveDef(privconn->storageState, pool, def) < 0) {
virStoragePoolObjRemove(pools, pool);
goto error;
}
@@ -404,7 +404,7 @@ parallelsPoolsAdd(virDomainObjPtr dom,
static int parallelsLoadPools(virConnectPtr conn)
{
parallelsConnPtr privconn = conn->privateData;
- virStorageDriverStatePtr storageState = conn->privateData->storageState;
+ virStorageDriverStatePtr storageState = privconn->storageState;
char *base = NULL;
size_t i;
@@ -461,6 +461,7 @@ parallelsStorageOpen(virConnectPtr conn,
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
unsigned int flags)
{
+ parallelsConnPtr privconn = conn->privateData;
virStorageDriverStatePtr storageState;
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
@@ -475,7 +476,7 @@ parallelsStorageOpen(virConnectPtr conn,
return VIR_DRV_OPEN_ERROR;
}
- conn->privateData->storageState = storageState;
+ privconn->storageState = storageState;
parallelsStorageLock(storageState);
if (parallelsLoadPools(conn))
@@ -728,7 +729,7 @@ parallelsStoragePoolDefineXML(virConnectPtr conn,
if (!(pool = virStoragePoolObjAssignDef(&privconn->pools, def)))
goto cleanup;
- if (virStoragePoolObjSaveDef(conn->privateData->storageState, pool, def) < 0) {
+ if (virStoragePoolObjSaveDef(privconn->storageState, pool, def) < 0) {
virStoragePoolObjRemove(&privconn->pools, pool);
def = NULL;
goto cleanup;
--
1.9.3
9 years, 11 months
[libvirt] [PATCHv3 00/16] Network configuration for lxc containers
by Cédric Bosdonnat
Hi all,
Here is a rebased version of v2. Nothing changed except the 'since' version number
in the added doc that has been updated.
--
Cedric
Cédric Bosdonnat (16):
Forgot to cleanup ifname_guest* in domain network def parsing
Domain conf: allow more than one IP address for net devices
LXC: set IP addresses to veth devices in the container
lxc conf2xml: convert IP addresses
Allow network capabilities hostdev to configure IP addresses
lxc conf2xml: convert ip addresses for hostdev NICs
Domain network devices can now have a <gateway> element
lxc conf2xml: convert lxc.network.ipv[46].gateway
LXC: use the new net devices gateway definition
LXC: honour network devices link state
Wrong place for virDomainNetIpsFormat
virNetDevSetIPv4Address: libnl implementation
Renamed virNetDevSetIPv4Address to virNetDevSetIPAddress
virNetDevAddRoute: implementation using netlink
virNetDevClearIPv4Address: netlink implementation
Renamed virNetDevClearIPv4Address to virNetDevClearIPAddress
docs/formatdomain.html.in | 39 +++
docs/schemas/domaincommon.rng | 55 +++-
src/conf/domain_conf.c | 214 +++++++++++++--
src/conf/domain_conf.h | 22 +-
src/libvirt_private.syms | 7 +-
src/lxc/lxc_container.c | 74 ++++-
src/lxc/lxc_native.c | 173 ++++++++----
src/network/bridge_driver.c | 4 +-
src/openvz/openvz_conf.c | 2 +-
src/openvz/openvz_driver.c | 6 +-
src/qemu/qemu_driver.c | 25 +-
src/qemu/qemu_hotplug.c | 6 +-
src/uml/uml_conf.c | 2 +-
src/util/virnetdev.c | 305 ++++++++++++++++++---
src/util/virnetdev.h | 12 +-
src/util/virnetlink.c | 38 +++
src/util/virnetlink.h | 2 +
src/vbox/vbox_common.c | 3 +-
src/xenconfig/xen_common.c | 15 +-
src/xenconfig/xen_sxpr.c | 12 +-
.../lxcconf2xmldata/lxcconf2xml-physnetwork.config | 4 +
tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml | 3 +
tests/lxcconf2xmldata/lxcconf2xml-simple.config | 4 +
tests/lxcconf2xmldata/lxcconf2xml-simple.xml | 3 +
tests/lxcxml2xmldata/lxc-hostdev.xml | 3 +
tests/lxcxml2xmldata/lxc-idmap.xml | 3 +
26 files changed, 880 insertions(+), 156 deletions(-)
--
1.8.4.5
9 years, 11 months
[libvirt] [PATCH v2 0/4] Precreate storage on migration
by Michal Privoznik
Version two of:
https://www.redhat.com/archives/libvir-list/2014-November/msg01048.html
diff to v1:
-Switch from qemuDomainGetBlockInfoImpl() to qemuMonitorBlockStatsUpdateCapacity()
-s/alloc/capacity/
-small fixes raised by Peter
Michal Privoznik (4):
storage: Introduce storagePoolLookupByPath
qemuMonitorJSONBlockStatsUpdateCapacity: Don't skip disks
qemu_migration: Send disk sizes to the other side
qemu_migration: Precreate missing storage
src/qemu/qemu_migration.c | 313 ++++++++++++++++++++++++++++++++++++++++---
src/qemu/qemu_monitor_json.c | 12 +-
src/storage/storage_driver.c | 36 +++++
src/storage/storage_driver.h | 4 +
4 files changed, 342 insertions(+), 23 deletions(-)
--
2.0.4
9 years, 11 months
[libvirt] [PATCH] nwfilter: fix crash when adding non-existing nwfilter
by Pavel Hrdina
Adding non-existing nwfilter to a network interface device without any
nwfilter specified will crash libvirt daemon with segfault. The reason is
that the nwfilter is not found an libvirt will try to restore old
nwfilter configuration but there is no nwfilter specified.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/conf/nwfilter_conf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index 074d745..317792e 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -2778,7 +2778,7 @@ virNWFilterObjFindByName(virNWFilterObjListPtr nwfilters, const char *name)
for (i = 0; i < nwfilters->count; i++) {
virNWFilterObjLock(nwfilters->objs[i]);
- if (STREQ(nwfilters->objs[i]->def->name, name))
+ if (STREQ_NULLABLE(nwfilters->objs[i]->def->name, name))
return nwfilters->objs[i];
virNWFilterObjUnlock(nwfilters->objs[i]);
}
--
2.0.4
9 years, 11 months
[libvirt] [PATCH] qemu: add tun devices to cgroup ACL
by rongqing.li@windriver.com
From: Roy Li <rongqing.li(a)windriver.com>
When systemd is used as init, CGroup will be enabled by default, and
lead to virsh unable to start VM(which is using the tun/tap), since
virsh can not access /dev/net/tun device
Signed-off-by: Roy Li <rongqing.li(a)windriver.com>
---
src/qemu/qemu.conf | 3 ++-
src/qemu/qemu_cgroup.c | 2 +-
src/qemu/test_libvirtd_qemu.aug.in | 1 +
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index c6db568..225cd0f 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -272,7 +272,8 @@
# "/dev/null", "/dev/full", "/dev/zero",
# "/dev/random", "/dev/urandom",
# "/dev/ptmx", "/dev/kvm", "/dev/kqemu",
-# "/dev/rtc","/dev/hpet", "/dev/vfio/vfio"
+# "/dev/rtc","/dev/hpet", "/dev/vfio/vfio",
+# "/dev/net/tun"
#]
#
# RDMA migration requires the following extra files to be added to the list:
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 0e94cae..7c15c07 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -45,7 +45,7 @@ static const char *const defaultDeviceACL[] = {
"/dev/random", "/dev/urandom",
"/dev/ptmx", "/dev/kvm", "/dev/kqemu",
"/dev/rtc", "/dev/hpet", "/dev/vfio/vfio",
- NULL,
+ "/dev/net/tun", NULL,
};
#define DEVICE_PTY_MAJOR 136
#define DEVICE_SND_MAJOR 116
diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in
index 30fd27e..2ab7a8d 100644
--- a/src/qemu/test_libvirtd_qemu.aug.in
+++ b/src/qemu/test_libvirtd_qemu.aug.in
@@ -48,6 +48,7 @@ module Test_libvirtd_qemu =
{ "9" = "/dev/rtc" }
{ "10" = "/dev/hpet" }
{ "11" = "/dev/vfio/vfio" }
+ { "12" = "/dev/net/tun" }
}
{ "save_image_format" = "raw" }
{ "dump_image_format" = "raw" }
--
2.1.0
9 years, 11 months
[libvirt] [PATCH] conf: fix a comment typo in virDomainVideoDefaultRAM
by Wang Rui
Signed-off-by: Wang Rui <moon.wangrui(a)huawei.com>
---
src/conf/domain_conf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fe9b986..2d81c37 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10221,7 +10221,7 @@ virDomainVideoDefaultRAM(const virDomainDef *def,
return 4 * 1024;
case VIR_DOMAIN_VIDEO_TYPE_QXL:
- /* QEMU use 64M as the minimal video video memory for qxl device */
+ /* QEMU use 64M as the minimal video memory for qxl device */
return 64 * 1024;
default:
--
1.7.12.4
9 years, 11 months
[libvirt] [PATCH] libvirt.c: Move virDomainGetFSInfo to libvirt-domain.c
by Michal Privoznik
Since our big split of libvirt.c there are only a few functions
living there. The majority was moved to corresponding subfile,
e.g. domain functions were moved to libvirt-domain.c. However,
the patches for virDomainGetFSInfo() and virDomainFSInfoFree()
introduction were posted prior the big split and merged after.
This resulted in two domain functions landing in wrong file.
Move them to the correct one.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/libvirt-domain.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/libvirt.c | 67 ----------------------------------------------------
2 files changed, 67 insertions(+), 67 deletions(-)
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 2b0defc..01bd9e4 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -11111,3 +11111,70 @@ virDomainStatsRecordListFree(virDomainStatsRecordPtr *stats)
VIR_FREE(stats);
}
+
+
+/**
+ * virDomainGetFSInfo:
+ * @dom: a domain object
+ * @info: a pointer to a variable to store an array of mount points information
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Get a list of mapping information for each mounted file systems within the
+ * specified guest and the disks.
+ *
+ * Returns the number of returned mount points, or -1 in case of error.
+ * On success, the array of the information is stored into @info. The caller is
+ * responsible for calling virDomainFSInfoFree() on each array element, then
+ * calling free() on @info. On error, @info is set to NULL.
+ */
+int
+virDomainGetFSInfo(virDomainPtr dom,
+ virDomainFSInfoPtr **info,
+ unsigned int flags)
+{
+ VIR_DOMAIN_DEBUG(dom, "info=%p, flags=%x", info, flags);
+
+ virResetLastError();
+
+ virCheckDomainReturn(dom, -1);
+ virCheckReadOnlyGoto(dom->conn->flags, error);
+ virCheckNonNullArgGoto(info, error);
+ *info = NULL;
+
+ if (dom->conn->driver->domainGetFSInfo) {
+ int ret = dom->conn->driver->domainGetFSInfo(dom, info, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virReportUnsupportedError();
+
+ error:
+ virDispatchError(dom->conn);
+ return -1;
+}
+
+
+/**
+ * virDomainFSInfoFree:
+ * @info: pointer to a FSInfo object
+ *
+ * Frees all the memory occupied by @info.
+ */
+void
+virDomainFSInfoFree(virDomainFSInfoPtr info)
+{
+ size_t i;
+
+ if (!info)
+ return;
+
+ VIR_FREE(info->mountpoint);
+ VIR_FREE(info->name);
+ VIR_FREE(info->fstype);
+
+ for (i = 0; i < info->ndevAlias; i++)
+ VIR_FREE(info->devAlias[i]);
+ VIR_FREE(info->devAlias);
+}
diff --git a/src/libvirt.c b/src/libvirt.c
index 86b0daa..d51c014 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -1400,73 +1400,6 @@ virConnectOpenAuth(const char *name,
}
-/**
- * virDomainGetFSInfo:
- * @dom: a domain object
- * @info: a pointer to a variable to store an array of mount points information
- * @flags: extra flags; not used yet, so callers should always pass 0
- *
- * Get a list of mapping information for each mounted file systems within the
- * specified guest and the disks.
- *
- * Returns the number of returned mount points, or -1 in case of error.
- * On success, the array of the information is stored into @info. The caller is
- * responsible for calling virDomainFSInfoFree() on each array element, then
- * calling free() on @info. On error, @info is set to NULL.
- */
-int
-virDomainGetFSInfo(virDomainPtr dom,
- virDomainFSInfoPtr **info,
- unsigned int flags)
-{
- VIR_DOMAIN_DEBUG(dom, "info=%p, flags=%x", info, flags);
-
- virResetLastError();
-
- virCheckDomainReturn(dom, -1);
- virCheckReadOnlyGoto(dom->conn->flags, error);
- virCheckNonNullArgGoto(info, error);
- *info = NULL;
-
- if (dom->conn->driver->domainGetFSInfo) {
- int ret = dom->conn->driver->domainGetFSInfo(dom, info, flags);
- if (ret < 0)
- goto error;
- return ret;
- }
-
- virReportUnsupportedError();
-
- error:
- virDispatchError(dom->conn);
- return -1;
-}
-
-
-/**
- * virDomainFSInfoFree:
- * @info: pointer to a FSInfo object
- *
- * Frees all the memory occupied by @info.
- */
-void
-virDomainFSInfoFree(virDomainFSInfoPtr info)
-{
- size_t i;
-
- if (!info)
- return;
-
- VIR_FREE(info->mountpoint);
- VIR_FREE(info->name);
- VIR_FREE(info->fstype);
-
- for (i = 0; i < info->ndevAlias; i++)
- VIR_FREE(info->devAlias[i]);
- VIR_FREE(info->devAlias);
-}
-
-
/**
* virConnectClose:
--
2.0.4
9 years, 11 months