[libvirt] [PATCH] lib: Use more of VIR_STEAL_PTR()
by Michal Privoznik
From: Your Name <you(a)example.com>
We have this very handy macro called VIR_STEAL_PTR() which steals
one pointer into the other and sets the other to NULL. The
following coccinelle patch was used to create this commit:
@ rule1 @
identifier a, b;
@@
- b = a;
...
- a = NULL;
+ VIR_STEAL_PTR(b, a);
Some places were clean up afterwards to make syntax-check happy
(e.g. some curly braces were removed where the body become a one
liner).
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/conf/domain_addr.c | 6 ++----
src/conf/domain_conf.c | 21 +++++++--------------
src/conf/secret_conf.c | 3 +--
src/conf/storage_conf.c | 3 +--
src/conf/virnetworkobj.c | 3 +--
src/conf/virsecretobj.c | 3 +--
src/libvirt-domain.c | 12 ++++--------
src/phyp/phyp_driver.c | 3 +--
src/qemu/qemu_domain.c | 6 ++----
src/qemu/qemu_driver.c | 12 ++++--------
src/qemu/qemu_migration.c | 12 ++++--------
src/security/virt-aa-helper.c | 3 +--
src/storage/storage_driver.c | 6 ++----
src/test/test_driver.c | 3 +--
src/util/virdbus.c | 18 ++++++------------
src/util/virrotatingfile.c | 3 +--
src/util/virstoragefile.c | 6 ++----
src/vz/vz_driver.c | 14 ++++----------
src/vz/vz_sdk.c | 6 ++----
tests/networkxml2conftest.c | 3 +--
tools/virsh-domain.c | 3 +--
tools/virsh-snapshot.c | 3 +--
22 files changed, 50 insertions(+), 102 deletions(-)
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 618fce44f0..04c4e6d7e1 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -1757,8 +1757,7 @@ virDomainVirtioSerialAddrSetCreateFromDomain(virDomainDefPtr def)
addrs) < 0)
goto cleanup;
- ret = addrs;
- addrs = NULL;
+ VIR_STEAL_PTR(ret, addrs);
cleanup:
virDomainVirtioSerialAddrSetFree(addrs);
return ret;
@@ -2095,8 +2094,7 @@ virDomainUSBAddressHubNew(size_t nports)
goto cleanup;
hub->nports = nports;
- ret = hub;
- hub = NULL;
+ VIR_STEAL_PTR(ret, hub);
cleanup:
virDomainUSBAddressHubFree(hub);
return ret;
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 22979e6c4e..9409d93c23 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7900,8 +7900,7 @@ virDomainNetIPParseXML(xmlNodePtr node)
goto cleanup;
}
- ret = ip;
- ip = NULL;
+ VIR_STEAL_PTR(ret, ip);
cleanup:
VIR_FREE(prefixStr);
@@ -13482,10 +13481,8 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
goto error;
}
- if (!address) {
- address = addressCompat;
- addressCompat = NULL;
- }
+ if (!address)
+ VIR_STEAL_PTR(address, addressCompat);
}
if (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET) {
@@ -13497,10 +13494,8 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
goto error;
}
- if (!socketPath) {
- socketPath = socketCompat;
- socketCompat = NULL;
- }
+ if (!socketPath)
+ VIR_STEAL_PTR(socketPath, socketCompat);
}
if (address && address[0] &&
@@ -14747,8 +14742,7 @@ virDomainShmemDefParseXML(virDomainXMLOptionPtr xmlopt,
goto cleanup;
- ret = def;
- def = NULL;
+ VIR_STEAL_PTR(ret, def);
cleanup:
ctxt->node = save;
VIR_FREE(tmp);
@@ -16187,8 +16181,7 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
}
}
- ret = iommu;
- iommu = NULL;
+ VIR_STEAL_PTR(ret, iommu);
cleanup:
ctxt->node = save;
diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c
index 3a5aa72563..ca6cc194a2 100644
--- a/src/conf/secret_conf.c
+++ b/src/conf/secret_conf.c
@@ -193,8 +193,7 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root)
if (virXPathNode("./usage", ctxt) != NULL
&& virSecretDefParseUsage(ctxt, def) < 0)
goto cleanup;
- ret = def;
- def = NULL;
+ VIR_STEAL_PTR(ret, def);
cleanup:
VIR_FREE(prop);
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 55db7a96f5..ba5b1f1783 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -587,8 +587,7 @@ virStoragePoolDefParseSourceString(const char *srcSpec,
node) < 0)
goto cleanup;
- ret = def;
- def = NULL;
+ VIR_STEAL_PTR(ret, def);
cleanup:
virStoragePoolSourceFree(def);
xmlFreeDoc(doc);
diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
index e6b01388f5..3749dda751 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -602,8 +602,7 @@ virNetworkObjAssignDefLocked(virNetworkObjListPtr nets,
obj->persistent = !(flags & VIR_NETWORK_OBJ_LIST_ADD_LIVE);
}
- ret = obj;
- obj = NULL;
+ VIR_STEAL_PTR(ret, obj);
cleanup:
virNetworkObjEndAPI(&obj);
diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c
index 78911c0908..c4e7b06eca 100644
--- a/src/conf/virsecretobj.c
+++ b/src/conf/virsecretobj.c
@@ -394,8 +394,7 @@ virSecretObjListAdd(virSecretObjListPtr secrets,
virObjectRef(obj);
}
- ret = obj;
- obj = NULL;
+ VIR_STEAL_PTR(ret, obj);
cleanup:
virSecretObjEndAPI(&obj);
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 75c9014c0e..d919a44803 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -3046,9 +3046,8 @@ virDomainMigrateVersion3Full(virDomainPtr domain,
VIR_MIGRATE_AUTO_CONVERGE);
VIR_DEBUG("Prepare3 %p flags=0x%x", dconn, destflags);
- cookiein = cookieout;
cookieinlen = cookieoutlen;
- cookieout = NULL;
+ VIR_STEAL_PTR(cookiein, cookieout);
cookieoutlen = 0;
if (useParams) {
if (virTypedParamsReplaceString(¶ms, &nparams,
@@ -3111,9 +3110,8 @@ virDomainMigrateVersion3Full(virDomainPtr domain,
*/
VIR_DEBUG("Perform3 %p uri=%s", domain->conn, uri);
VIR_FREE(cookiein);
- cookiein = cookieout;
cookieinlen = cookieoutlen;
- cookieout = NULL;
+ VIR_STEAL_PTR(cookiein, cookieout);
cookieoutlen = 0;
/* dconnuri not relevant in non-P2P modes, so left NULL here */
if (useParams) {
@@ -3150,9 +3148,8 @@ virDomainMigrateVersion3Full(virDomainPtr domain,
*/
VIR_DEBUG("Finish3 %p ret=%d", dconn, ret);
VIR_FREE(cookiein);
- cookiein = cookieout;
cookieinlen = cookieoutlen;
- cookieout = NULL;
+ VIR_STEAL_PTR(cookiein, cookieout);
cookieoutlen = 0;
if (useParams) {
if (virTypedParamsGetString(params, nparams,
@@ -3227,9 +3224,8 @@ virDomainMigrateVersion3Full(virDomainPtr domain,
if (notify_source) {
VIR_DEBUG("Confirm3 %p ret=%d domain=%p", domain->conn, ret, domain);
VIR_FREE(cookiein);
- cookiein = cookieout;
cookieinlen = cookieoutlen;
- cookieout = NULL;
+ VIR_STEAL_PTR(cookiein, cookieout);
cookieoutlen = 0;
if (useParams) {
ret = domain->conn->driver->domainMigrateConfirm3Params
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 4acc6ce734..4ffa08ff43 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -1468,8 +1468,7 @@ phypGetBackingDevice(virConnectPtr conn, const char *managed_system,
if (VIR_STRDUP(backing_device, char_ptr) < 0)
goto cleanup;
} else {
- backing_device = ret;
- ret = NULL;
+ VIR_STEAL_PTR(backing_device, ret);
}
char_ptr = strchr(backing_device, '\n');
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index f42903a343..6eeabe0df1 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -11645,8 +11645,7 @@ qemuDomainCreateDeviceRecursive(const char *device,
}
VIR_FREE(devTmp);
VIR_FREE(target);
- target = tmp;
- tmp = NULL;
+ VIR_STEAL_PTR(target, tmp);
}
if (qemuDomainCreateDeviceRecursive(target, data,
@@ -12601,8 +12600,7 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
}
VIR_FREE(fileTmp);
VIR_FREE(target);
- target = tmp;
- tmp = NULL;
+ VIR_STEAL_PTR(target, tmp);
}
data.target = target;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2d8e4618bd..5387150bbd 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6655,11 +6655,9 @@ qemuDomainSaveImageUpdateDef(virQEMUDriverPtr driver,
virFreeError(err);
/* use the user provided XML */
- ret = newdef;
- newdef = NULL;
+ VIR_STEAL_PTR(ret, newdef);
} else {
- ret = newdef_migr;
- newdef_migr = NULL;
+ VIR_STEAL_PTR(ret, newdef_migr);
}
cleanup:
@@ -12705,10 +12703,8 @@ qemuDomainMigratePerform(virDomainPtr dom,
goto cleanup;
}
- if (flags & VIR_MIGRATE_PEER2PEER) {
- dconnuri = uri;
- uri = NULL;
- }
+ if (flags & VIR_MIGRATE_PEER2PEER)
+ VIR_STEAL_PTR(dconnuri, uri);
/* Do not output cookies in v2 protocol, since the cookie
* length was not sufficiently large, causing failures
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 950d9cd615..6c66ff6648 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -4170,9 +4170,8 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriverPtr driver,
VIR_MIGRATE_AUTO_CONVERGE);
VIR_DEBUG("Prepare3 %p", dconn);
- cookiein = cookieout;
cookieinlen = cookieoutlen;
- cookieout = NULL;
+ VIR_STEAL_PTR(cookiein, cookieout);
cookieoutlen = 0;
if (flags & VIR_MIGRATE_TUNNELLED) {
if (!(st = virStreamNew(dconn, 0)))
@@ -4239,9 +4238,8 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriverPtr driver,
VIR_DEBUG("Perform3 %p uri=%s", sconn, NULLSTR(uri));
qemuMigrationJobSetPhase(driver, vm, QEMU_MIGRATION_PHASE_PERFORM3);
VIR_FREE(cookiein);
- cookiein = cookieout;
cookieinlen = cookieoutlen;
- cookieout = NULL;
+ VIR_STEAL_PTR(cookiein, cookieout);
cookieoutlen = 0;
if (flags & VIR_MIGRATE_TUNNELLED) {
ret = qemuMigrationSrcPerformTunnel(driver, vm, st, persist_xml,
@@ -4281,9 +4279,8 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriverPtr driver,
*/
VIR_DEBUG("Finish3 %p ret=%d", dconn, ret);
VIR_FREE(cookiein);
- cookiein = cookieout;
cookieinlen = cookieoutlen;
- cookieout = NULL;
+ VIR_STEAL_PTR(cookiein, cookieout);
cookieoutlen = 0;
if (useParams) {
@@ -4362,9 +4359,8 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriverPtr driver,
*/
VIR_DEBUG("Confirm3 %p cancelled=%d vm=%p", sconn, cancelled, vm);
VIR_FREE(cookiein);
- cookiein = cookieout;
cookieinlen = cookieoutlen;
- cookieout = NULL;
+ VIR_STEAL_PTR(cookiein, cookieout);
cookieoutlen = 0;
ret = qemuMigrationSrcConfirmPhase(driver, vm,
cookiein, cookieinlen,
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 56d7cfadf1..8e22e9978a 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -355,8 +355,7 @@ create_profile(const char *profile, const char *profile_name,
if (!(tmp = virStringReplace(pcontent, template_end, replace_files)))
goto clean_all;
VIR_FREE(pcontent);
- pcontent = tmp;
- tmp = NULL;
+ VIR_STEAL_PTR(pcontent, tmp);
}
/* write the file */
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 4a13e90481..878a40cac5 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -1936,8 +1936,7 @@ storageVolCreateXML(virStoragePoolPtr pool,
VIR_INFO("Creating volume '%s' in storage pool '%s'",
newvol->name, def->name);
- vol = newvol;
- newvol = NULL;
+ VIR_STEAL_PTR(vol, newvol);
voldef = NULL;
cleanup:
@@ -2130,8 +2129,7 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool,
VIR_INFO("Creating volume '%s' in storage pool '%s'",
newvol->name, def->name);
- vol = newvol;
- newvol = NULL;
+ VIR_STEAL_PTR(vol, newvol);
voldef = NULL;
cleanup:
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 1d81772a46..568c52aa28 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -5595,8 +5595,7 @@ testNodeDeviceCreateXML(virConnectPtr conn,
if (VIR_STRDUP(dev->parentName, def->parent) < 0)
goto cleanup;
- ret = dev;
- dev = NULL;
+ VIR_STEAL_PTR(ret, dev);
cleanup:
virNodeDeviceObjEndAPI(&obj);
diff --git a/src/util/virdbus.c b/src/util/virdbus.c
index 691f182387..6725e0edb0 100644
--- a/src/util/virdbus.c
+++ b/src/util/virdbus.c
@@ -762,8 +762,7 @@ virDBusMessageIterEncode(DBusMessageIter *rootiter,
goto cleanup;
}
VIR_FREE(contsig);
- iter = newiter;
- newiter = NULL;
+ VIR_STEAL_PTR(iter, newiter);
types = t + 1;
nstruct = skiplen;
narray = (size_t)va_arg(args, int);
@@ -789,8 +788,7 @@ virDBusMessageIterEncode(DBusMessageIter *rootiter,
VIR_FREE(newiter);
goto cleanup;
}
- iter = newiter;
- newiter = NULL;
+ VIR_STEAL_PTR(iter, newiter);
types = vsig;
nstruct = strlen(types);
narray = (size_t)-1;
@@ -821,8 +819,7 @@ virDBusMessageIterEncode(DBusMessageIter *rootiter,
goto cleanup;
}
VIR_FREE(contsig);
- iter = newiter;
- newiter = NULL;
+ VIR_STEAL_PTR(iter, newiter);
types = t + 1;
nstruct = skiplen - 2;
narray = (size_t)-1;
@@ -1059,8 +1056,7 @@ virDBusMessageIterDecode(DBusMessageIter *rootiter,
nstruct, narray) < 0)
goto cleanup;
VIR_FREE(contsig);
- iter = newiter;
- newiter = NULL;
+ VIR_STEAL_PTR(iter, newiter);
types = t + 1;
nstruct = skiplen;
if (arrayref) {
@@ -1090,8 +1086,7 @@ virDBusMessageIterDecode(DBusMessageIter *rootiter,
VIR_DEBUG("Push failed");
goto cleanup;
}
- iter = newiter;
- newiter = NULL;
+ VIR_STEAL_PTR(iter, newiter);
types = vsig;
nstruct = strlen(types);
narray = (size_t)-1;
@@ -1118,8 +1113,7 @@ virDBusMessageIterDecode(DBusMessageIter *rootiter,
nstruct, narray) < 0)
goto cleanup;
VIR_FREE(contsig);
- iter = newiter;
- newiter = NULL;
+ VIR_STEAL_PTR(iter, newiter);
types = t + 1;
nstruct = skiplen - 2;
narray = (size_t)-1;
diff --git a/src/util/virrotatingfile.c b/src/util/virrotatingfile.c
index d7dc3bd1ce..7a268319a6 100644
--- a/src/util/virrotatingfile.c
+++ b/src/util/virrotatingfile.c
@@ -406,8 +406,7 @@ virRotatingFileWriterRollover(virRotatingFileWriterPtr file)
}
VIR_FREE(nextpath);
- nextpath = thispath;
- thispath = NULL;
+ VIR_STEAL_PTR(nextpath, thispath);
}
}
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index bd4b0274df..70fe551e5f 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1233,8 +1233,7 @@ virStorageFileGetMetadataFromFD(const char *path,
* update the metadata.*/
meta->type = VIR_STORAGE_TYPE_DIR;
meta->format = VIR_STORAGE_FILE_DIR;
- ret = meta;
- meta = NULL;
+ VIR_STEAL_PTR(ret, meta);
goto cleanup;
}
@@ -1256,8 +1255,7 @@ virStorageFileGetMetadataFromFD(const char *path,
else if (S_ISBLK(sb.st_mode))
meta->type = VIR_STORAGE_TYPE_BLOCK;
- ret = meta;
- meta = NULL;
+ VIR_STEAL_PTR(ret, meta);
cleanup:
virStorageSourceFree(meta);
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 7e9ef932dc..e86a788b09 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -182,12 +182,8 @@ vzDestroyDriverConnection(void)
vzConnPtr privconn_list;
virMutexLock(&vz_driver_lock);
- driver = vz_driver;
- vz_driver = NULL;
-
- privconn_list = vz_conn_list;
- vz_conn_list = NULL;
-
+ VIR_STEAL_PTR(driver, vz_driver);
+ VIR_STEAL_PTR(privconn_list, vz_conn_list);
virMutexUnlock(&vz_driver_lock);
while (privconn_list) {
@@ -3203,9 +3199,8 @@ vzDomainMigratePerformP2P(virDomainObjPtr dom,
VIR_MIGRATE_PARAM_DEST_XML, dom_xml) < 0)
goto done;
- cookiein = cookieout;
cookieinlen = cookieoutlen;
- cookieout = NULL;
+ VIR_STEAL_PTR(cookiein, cookieout);
cookieoutlen = 0;
virObjectUnlock(dom);
ret = dconn->driver->domainMigratePrepare3Params
@@ -3226,9 +3221,8 @@ vzDomainMigratePerformP2P(virDomainObjPtr dom,
}
VIR_FREE(cookiein);
- cookiein = cookieout;
cookieinlen = cookieoutlen;
- cookieout = NULL;
+ VIR_STEAL_PTR(cookiein, cookieout);
cookieoutlen = 0;
if (vzDomainMigratePerformStep(dom, driver, params, nparams, cookiein,
cookieinlen, flags) < 0) {
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 63d013deac..b9fd03c0d2 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -928,8 +928,7 @@ prlsdkParseNetAddress(char *addr)
goto cleanup;
ip->prefix = nbits;
- ret = ip;
- ip = NULL;
+ VIR_STEAL_PTR(ret, ip);
cleanup:
if (!ret)
@@ -4768,8 +4767,7 @@ prlsdkParseSnapshotTree(const char *treexml)
goto cleanup;
}
- ret = snapshots;
- snapshots = NULL;
+ VIR_STEAL_PTR(ret, snapshots);
cleanup:
virDomainSnapshotObjListFree(snapshots);
diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c
index 367e30b994..c362149c29 100644
--- a/tests/networkxml2conftest.c
+++ b/tests/networkxml2conftest.c
@@ -51,8 +51,7 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf, dnsmasqCapsPtr
"except-interface=lo\n")))
goto fail;
VIR_FREE(actual);
- actual = tmp;
- tmp = NULL;
+ VIR_STEAL_PTR(actual, tmp);
#endif
if (virTestCompareToFile(actual, outconf) < 0)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index e63fc028b9..34f9e6b5c6 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -8423,8 +8423,7 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
}
VIR_FREE(desc);
- desc = desc_edited;
- desc_edited = NULL;
+ VIR_STEAL_PTR(desc, desc_edited);
}
if (virDomainSetMetadata(dom, type, desc, NULL, NULL, flags) < 0) {
diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index e3d4cda0fc..6d8e2b299b 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -1356,8 +1356,7 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPtr dom,
virshSnapSorter);
snaplist->nsnaps -= deleted;
- ret = snaplist;
- snaplist = NULL;
+ VIR_STEAL_PTR(ret, snaplist);
cleanup:
virshSnapshotListFree(snaplist);
--
2.19.2
5 years, 10 months
[libvirt] [PATCH] virfile: Detect ceph as shared FS
by Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=1665553
Ceph can be mounted just like any other filesystem and in fact is
a shared and cluster filesystem.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/util/virfile.c | 9 ++++++++-
src/util/virfile.h | 1 +
src/util/virstoragefile.c | 3 ++-
tests/virfiledata/mounts3.txt | 2 ++
tests/virfilemock.c | 5 +++++
tests/virfiletest.c | 1 +
6 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 263c92667c..271bf5e796 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -3465,6 +3465,9 @@ int virFilePrintf(FILE *fp, const char *msg, ...)
# ifndef FUSE_SUPER_MAGIC
# define FUSE_SUPER_MAGIC 0x65735546
# endif
+# ifndef CEPH_SUPER_MAGIC
+# define CEPH_SUPER_MAGIC 0x00C36400
+# endif
# define PROC_MOUNTS "/proc/mounts"
@@ -3607,6 +3610,9 @@ virFileIsSharedFSType(const char *path,
if ((fstypes & VIR_FILE_SHFS_CIFS) &&
(f_type == CIFS_SUPER_MAGIC))
return 1;
+ if ((fstypes & VIR_FILE_SHFS_CEPH) &&
+ (f_type == CEPH_SUPER_MAGIC))
+ return 1;
return 0;
}
@@ -3769,7 +3775,8 @@ int virFileIsSharedFS(const char *path)
VIR_FILE_SHFS_OCFS |
VIR_FILE_SHFS_AFS |
VIR_FILE_SHFS_SMB |
- VIR_FILE_SHFS_CIFS);
+ VIR_FILE_SHFS_CIFS |
+ VIR_FILE_SHFS_CEPH);
}
diff --git a/src/util/virfile.h b/src/util/virfile.h
index 93484e5444..65432da13a 100644
--- a/src/util/virfile.h
+++ b/src/util/virfile.h
@@ -220,6 +220,7 @@ enum {
VIR_FILE_SHFS_AFS = (1 << 3),
VIR_FILE_SHFS_SMB = (1 << 4),
VIR_FILE_SHFS_CIFS = (1 << 5),
+ VIR_FILE_SHFS_CEPH = (1 << 6),
};
int virFileIsSharedFSType(const char *path, int fstypes) ATTRIBUTE_NONNULL(1);
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index bd4b0274df..895c8f90de 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1359,7 +1359,8 @@ int virStorageFileIsClusterFS(const char *path)
*/
return virFileIsSharedFSType(path,
VIR_FILE_SHFS_GFS2 |
- VIR_FILE_SHFS_OCFS);
+ VIR_FILE_SHFS_OCFS |
+ VIR_FILE_SHFS_CEPH);
}
#ifdef LVS
diff --git a/tests/virfiledata/mounts3.txt b/tests/virfiledata/mounts3.txt
index 134c6e8f81..68eded048c 100644
--- a/tests/virfiledata/mounts3.txt
+++ b/tests/virfiledata/mounts3.txt
@@ -33,3 +33,5 @@ host:/nfs /nfs nfs4 rw,relatime,vers=4.1,rsize=1048576,wsize=1048576,namlen=255,
dev /nfs/blah devtmpfs rw,nosuid,relatime,size=10240k,nr_inodes=4093060,mode=755 0 0
host:/gv0 /gluster fuse.glusterfs rw 0 0
root@host:/tmp/mkdir /gluster/sshfs fuse.sshfs rw 0 0
+192.168.0.1:/ceph/data /ceph ceph rw,noatime,name=cephfs,secret=<hidden>,acl,wsize=16777216 0 0
+192.168.0.1,192.168.0.2,192.168.0.3:/ceph/data2 /ceph/multi ceph rw,noatime,name=cephfs,secret=<hidden>,acl,wsize=16777216 0 0
diff --git a/tests/virfilemock.c b/tests/virfilemock.c
index fb6bd5e699..499135d773 100644
--- a/tests/virfilemock.c
+++ b/tests/virfilemock.c
@@ -86,6 +86,9 @@ setmntent(const char *filename, const char *type)
#ifndef FUSE_SUPER_MAGIC
# define FUSE_SUPER_MAGIC 0x65735546
#endif
+#ifndef CEPH_SUPER_MAGIC
+# define CEPH_SUPER_MAGIC 0x00c36400
+#endif
static int
@@ -132,6 +135,8 @@ statfs_mock(const char *mtab,
ftype = CIFS_SUPER_MAGIC;
} else if (STRPREFIX(mb.mnt_type, "fuse")) {
ftype = FUSE_SUPER_MAGIC;
+ } else if (STRPREFIX(mb.mnt_type, "ceph")) {
+ ftype = CEPH_SUPER_MAGIC;
} else {
/* Everything else is EXT4. We don't care really for other paths. */
ftype = EXT4_SUPER_MAGIC;
diff --git a/tests/virfiletest.c b/tests/virfiletest.c
index b1cb831bfd..6cc599a81b 100644
--- a/tests/virfiletest.c
+++ b/tests/virfiletest.c
@@ -455,6 +455,7 @@ mymain(void)
DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/gluster/file", true);
DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/gluster/sshfs/file", false);
DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/some/symlink/file", true);
+ DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/ceph/file", true);
return ret != 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}
--
2.19.2
5 years, 10 months
[libvirt] [PATCH 0/2] add debugcon-isa chardev guest interface
by Nikolay Shirokovskiy
It corresponds to QEMU's isa-debugcon device. It can be used
to output debug info by firmware at least.
I do not introduce capability to test for the device because it was
supported long before current minimal 1.5.0 version.
Nikolay Shirokovskiy (2):
conf: add debugcon-isa chardev guest interface
qemu: implement debugcon-isa chardev
docs/formatdomain.html.in | 11 ++++++
docs/schemas/domaincommon.rng | 8 +++++
src/conf/domain_conf.c | 6 +++-
src/conf/domain_conf.h | 1 +
src/libvirt_private.syms | 2 ++
src/qemu/qemu_command.c | 13 +++++++
src/qemu/qemu_domain.c | 20 +++++++++++
tests/qemuxml2argvdata/channel-debugcon-isa.args | 29 ++++++++++++++++
tests/qemuxml2argvdata/channel-debugcon-isa.xml | 34 +++++++++++++++++++
tests/qemuxml2argvtest.c | 1 +
tests/qemuxml2xmloutdata/channel-debugcon-isa.xml | 41 +++++++++++++++++++++++
tests/qemuxml2xmltest.c | 1 +
12 files changed, 166 insertions(+), 1 deletion(-)
create mode 100644 tests/qemuxml2argvdata/channel-debugcon-isa.args
create mode 100644 tests/qemuxml2argvdata/channel-debugcon-isa.xml
create mode 100644 tests/qemuxml2xmloutdata/channel-debugcon-isa.xml
--
1.8.3.1
5 years, 10 months
[libvirt] [PATCH 0/3] Facilitate running libvirt builds via docker including cross-compilation
by Daniel P. Berrangé
For a while QEMU has provided simple make rules for building QEMU inside
standard docker container environments. This provides an equivalent
mechanism for libvirt inspired by QEMU's.
This series depends on the cross compiler images defined by:
https://www.redhat.com/archives/libvir-list/2019-January/msg01039.html
QEMU actually builds the container images on developer's machines
locally. Libvirt already hosts pre-built images on quay.io, so that is
used directly as it is quicker to download these than build them locally
each time.
Daniel P. Berrangé (3):
tests: add targets for building libvirt inside docker containers
tests: add cross compiler images to CI test help output
tests: perform cross compiler builds on GitLab CI
.gitignore | 1 +
.gitlab-ci.yml | 38 ++++++++++++
Makefile.am | 2 +
tests/Makefile.ci.inc | 134 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 175 insertions(+)
create mode 100644 .gitlab-ci.yml
create mode 100644 tests/Makefile.ci.inc
--
2.20.1
5 years, 10 months
[libvirt] [PATCH v2 0/1] qemu_hotplug.c: check address before hotplug
by Daniel Henrique Barboza
Changes in v2:
- removed the function to check for alias
- added a new function to check for address in the VM definition
Daniel Henrique Barboza (1):
qemu_hotplug.c: check disk address before hotplug
src/qemu/qemu_hotplug.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
--
2.20.1
5 years, 11 months
[libvirt] [PATCH 0/3] Fixes for GPL / LGPL statements
by Thomas Huth
Here are some fixes for files in libvirt where the GPL or LGPL
statements are slightly wrong.
Thomas Huth (3):
bootstrap.conf: Fix LGPL information
tools/virt-xml-validate: Fix GPL information
docs/governance: Clarify the version number of the LGPL
bootstrap.conf | 2 +-
docs/governance.html.in | 2 +-
tools/virt-xml-validate.in | 5 ++---
3 files changed, 4 insertions(+), 5 deletions(-)
--
1.8.3.1
5 years, 11 months
[libvirt] [PATCH 0/2] virjson improvements [incremental backup saga]
by Eric Blake
Upstream qemu stabilized the QMP command block-dirty-bitmap-merge
to take an array of strings as the sources to merge into a destination
bitmap; this is a lot nicer for libvirt, compared to the alternative
where qemu 3.1 x-block-dirty-bitmap-merge had to be called multiple
times with the potential for some odd cleanup after partial failure
scenarios.
This series prepares virjson for use in my incremental backup work.
Eric Blake (2):
virjson: always raise vir error on append failures
virjson: add convenience wrapper for appending string to array
src/util/virjson.h | 2 ++
src/libvirt_private.syms | 1 +
src/util/virjson.c | 28 +++++++++++++++++++++++++---
3 files changed, 28 insertions(+), 3 deletions(-)
--
2.20.1
5 years, 11 months
[libvirt] [PATCH] tools: Document completer callback
by Michal Privoznik
Strictly speaking, this should go near vshCompleter typedef
declaration. However, I find it more useful near actual completer
implementations.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tools/virsh-completer.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c
index cfbfeae328..7a637a0cfa 100644
--- a/tools/virsh-completer.c
+++ b/tools/virsh-completer.c
@@ -35,6 +35,38 @@
#include "virxml.h"
+/**
+ * A completer callback is a function that accepts three arguments:
+ *
+ * @ctl: virsh control structure
+ * @cmd: parsed input
+ * @flags: optional flags to alter completer's behaviour
+ *
+ * The @ctl contains connection to the daemon (should completer
+ * need it). Any completer that requires connection must check
+ * whether connection is still alive.
+ *
+ * The @cmd then holds parsed user input which might be missing
+ * some arguments (user is still typing the command), but may
+ * already contain important data. For instance if completer
+ * needs domain XML it may inspect @cmd to find --domain. Using
+ * existing wrappers is advised. If @cmd does not contain all
+ * necessary bits, completer might return sensible defaults (i.e.
+ * generic values not tailored to specific use case) or return
+ * NULL (i.e. no strings are offered to the user for completion).
+ *
+ * The @flags then contain .completer_flags value defined for
+ * each use or 0 if no .completer_flags were specified. If a
+ * completer is generic enough @flags can be used to alter it's
+ * behaviour. For instance, a completer to fetch names of domains
+ * can use @flags to return names of only domains in particular
+ * state that the command accepts.
+ *
+ * Under no circumstances a completer can output anything. Nor to
+ * stdout nor to stderr. This would harm the user experience.
+ */
+
+
char **
virshDomainNameCompleter(vshControl *ctl,
const vshCmd *cmd ATTRIBUTE_UNUSED,
--
2.19.2
5 years, 11 months
[libvirt] [PATCH v2 0/3] Rebase LXC network definition to support version 3.0
by Julio Faracco
The series propose a new way to define NICs inside LXC native. It is
needed because LXC version 3.X uses indexes to define NICs and the
current algorithm is not able to support them. At least, if you consider
settings defined using a random logic.
v1-v2: Includes Michal's suggestions.
Julio Faracco (3):
lxc: refactoring LXC network definition with a sparse array.
tests: Change legacy network configs to version 3.0 with indexes.
tests: Include a random network testcase to test indexes.
src/lxc/lxc_native.c | 195 ++++++++++++------
.../lxcconf2xml-ethernet-v3.config | 16 +-
.../lxcconf2xml-fstab-v3.config | 10 +-
.../lxcconf2xml-macvlannetwork-v3.config | 10 +-
.../lxcconf2xml-miscnetwork-v3.config | 38 ++--
.../lxcconf2xml-physnetwork-v3.config | 14 +-
.../lxcconf2xml-simple-v3.config | 18 +-
.../lxcconf2xml-vlannetwork-v3.config | 10 +-
tests/lxcconf2xmltest.c | 1 +
9 files changed, 187 insertions(+), 125 deletions(-)
--
2.19.1
5 years, 11 months
[libvirt] [PATCH] virPortAllocatorSetUsed: ignore port 0
by Ján Tomko
Similar to what commit 86dba8f3 did for virPortAllocatorRelease,
ignore port 0 in virPortAllocatorSetUsed.
For all the reasonable use cases the callers already check that
the port is non-zero, however if the port from the XML overflows
unsigned short and turns into 0, it can be set as used by
virPortAllocatorSetUsed but not released by virPortAllocatorRelease.
Also skip port '0' in virPortAllocatorSetUsed to make this behavior
symmetric.
The serenity was disturbed by commit 5dbda5e9 which started using
virPortAllocatorRelease instead of virPortAllocatorSetUsed (false).
https://bugzilla.redhat.com/show_bug.cgi?id=1591645
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/util/virportallocator.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/util/virportallocator.c b/src/util/virportallocator.c
index db95a601c7..d48963c1ff 100644
--- a/src/util/virportallocator.c
+++ b/src/util/virportallocator.c
@@ -294,6 +294,9 @@ virPortAllocatorSetUsed(unsigned short port)
if (!pa)
return -1;
+ if (!port)
+ return 0;
+
virObjectLock(pa);
if (virBitmapIsBitSet(pa->bitmap, port) ||
--
2.16.4
5 years, 11 months