[libvirt] [PATCH] Replacing for (; ; ) with while (1) for better code.
by Nitesh Konkar
As mentioned in https://libvirt.org/hacking.html,
using while (1) is better than for (;;).
---
src/libvirt-stream.c | 4 ++--
src/phyp/phyp_driver.c | 2 +-
src/qemu/qemu_migration.c | 2 +-
src/remote/remote_driver.c | 2 +-
src/rpc/virnetclient.c | 6 +++---
src/security/security_selinux.c | 2 +-
src/util/vircgroup.c | 2 +-
src/util/vircommand.c | 2 +-
src/util/virdbus.c | 4 ++--
src/util/virfile.c | 2 +-
tests/commandhelper.c | 2 +-
11 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/libvirt-stream.c b/src/libvirt-stream.c
index 8384b37..41daaa1 100644
--- a/src/libvirt-stream.c
+++ b/src/libvirt-stream.c
@@ -349,7 +349,7 @@ virStreamSendAll(virStreamPtr stream,
if (VIR_ALLOC_N(bytes, want) < 0)
goto cleanup;
- for (;;) {
+ while (1) {
int got, offset = 0;
got = (handler)(stream, bytes, want, opaque);
if (got < 0) {
@@ -443,7 +443,7 @@ virStreamRecvAll(virStreamPtr stream,
if (VIR_ALLOC_N(bytes, want) < 0)
goto cleanup;
- for (;;) {
+ while (1) {
int got, offset = 0;
got = virStreamRecv(stream, bytes, want);
if (got < 0)
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 3dd8927..50cf1ae 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -187,7 +187,7 @@ phypExec(LIBSSH2_SESSION *session, const char *cmd, int *exit_status,
if (rc != 0)
goto err;
- for (;;) {
+ while (1) {
/* loop until we block */
do {
rc = libssh2_channel_read(channel, buffer, buffer_size);
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 8a220d9..bc7d268 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -4398,7 +4398,7 @@ static void qemuMigrationIOFunc(void *arg)
fds[0].fd = data->sock;
fds[1].fd = data->wakeupRecvFD;
- for (;;) {
+ while (1) {
int ret;
fds[0].events = fds[1].events = POLLIN;
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 3b8b796..b0c4440 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -4055,7 +4055,7 @@ remoteAuthSASL(virConnectPtr conn, struct private_data *priv,
/* Loop-the-loop...
* Even if the server has completed, the client must *always* do at least one step
* in this loop to verify the server isn't lying about something. Mutual auth */
- for (;;) {
+ while (1) {
if ((err = virNetSASLSessionClientStep(sasl,
serverin,
serverinlen,
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index 361dc1a..f3457be 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -777,7 +777,7 @@ int virNetClientSetTLSSession(virNetClientPtr client,
virNetSocketSetTLSSession(client->sock, client->tls);
- for (;;) {
+ while (1) {
ret = virNetTLSSessionHandshake(client->tls);
if (ret < 0)
@@ -1258,7 +1258,7 @@ virNetClientIOHandleInput(virNetClientPtr client)
/* Read as much data as is available, until we get
* EAGAIN
*/
- for (;;) {
+ while (1) {
ssize_t ret;
if (client->msg.nfds == 0) {
@@ -1463,7 +1463,7 @@ static int virNetClientIOEventLoop(virNetClientPtr client,
fds[0].fd = virNetSocketGetFD(client->sock);
fds[1].fd = client->wakeupReadFD;
- for (;;) {
+ while (1) {
char ignore;
sigset_t oldmask, blockedsigs;
int timeout = -1;
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 4be946d..153e6e9 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -137,7 +137,7 @@ virSecuritySELinuxMCSFind(virSecurityManagerPtr mgr,
VIR_DEBUG("Using sensitivity level '%s' cat min %d max %d range %d",
sens, catMin, catMax, catRange);
- for (;;) {
+ while (1) {
int c1 = virRandomInt(catRange);
int c2 = virRandomInt(catRange);
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 8b52816..cc83cf7 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1587,7 +1587,7 @@ virCgroupNewMachineSystemd(const char *name,
goto cleanup;
- for (;;) {
+ while (1) {
virCgroupPtr tmp;
char *t = strchr(offset + 1, '/');
if (t)
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 2a59bd1..bfc130d 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -2033,7 +2033,7 @@ virCommandProcessIO(virCommandPtr cmd)
goto cleanup;
ret = -1;
- for (;;) {
+ while (1) {
size_t i;
struct pollfd fds[3];
int nfds = 0;
diff --git a/src/util/virdbus.c b/src/util/virdbus.c
index 3f4dbe3..413229c 100644
--- a/src/util/virdbus.c
+++ b/src/util/virdbus.c
@@ -627,7 +627,7 @@ virDBusMessageIterEncode(DBusMessageIter *rootiter,
narray = (size_t)-1;
nstruct = strlen(types);
- for (;;) {
+ while (1) {
const char *t;
VIR_DEBUG("Loop nstack=%zu narray=%zd nstruct=%zu types='%s'",
@@ -904,7 +904,7 @@ virDBusMessageIterDecode(DBusMessageIter *rootiter,
narray = (size_t)-1;
nstruct = strlen(types);
- for (;;) {
+ while (1) {
const char *t;
bool advanceiter = true;
diff --git a/src/util/virfile.c b/src/util/virfile.c
index a45279a..f246b29 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -1269,7 +1269,7 @@ saferead_lim(int fd, size_t max_len, size_t *length)
size_t size = 0;
int save_errno;
- for (;;) {
+ while (1) {
int count;
int requested;
diff --git a/tests/commandhelper.c b/tests/commandhelper.c
index 015efda..5a77108 100644
--- a/tests/commandhelper.c
+++ b/tests/commandhelper.c
@@ -138,7 +138,7 @@ int main(int argc, char **argv) {
fprintf(stderr, "BEGIN STDERR\n");
fflush(stderr);
- for (;;) {
+ while (1) {
got = read(STDIN_FILENO, buf, sizeof(buf));
if (got < 0)
goto cleanup;
--
2.1.0
8 years, 2 months
[libvirt] [PATCH 0/9] Couple of vhost-user fixes and cleanups
by Michal Privoznik
While working on this, I've discovered a qemu crasher [1], so
there are not tested properly. If you have pointers how to test
vhost-user without need to install openvswitch, I'm all ears.
1: http://lists.nongnu.org/archive/html/qemu-devel/2016-08/msg02933.html
Michal Privoznik (9):
qemuDomainAttachNetDevice: Explicitly list allowed types for hotplug
qemuDomain{Attach,Remove}NetDevice: Prefer qemuDomainSupportsNetdev
qemuBuildChrChardevStr: Introduce @nowait argument
qemuBuildVhostuserCommandLine: Reuse qemuBuildChrChardevStr
qemuBuildHostNetStr: Realign
qemuBuildHostNetStr: Explicitly enumerate net types
qemuBuildVhostuserCommandLine: Unify -netdev creation
qemuBuildHostNetStr: Support VIR_DOMAIN_NET_TYPE_VHOSTUSER
qemu_hotplug: Support interface type of vhost-user hotplug
src/qemu/qemu_command.c | 169 ++++++++++++---------
src/qemu/qemu_hotplug.c | 83 ++++++++--
.../qemuxml2argv-net-vhostuser-multiq.args | 6 +-
.../qemuxml2argv-net-vhostuser.args | 4 +-
4 files changed, 176 insertions(+), 86 deletions(-)
--
2.8.4
8 years, 2 months
[libvirt] [PATCH] virsh: send-process-signal: add support for '-NUM' style of signal nums
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)gmail.com>
As kill(1), add support for sending signal
in form of "9" as well as "-9".
Signed-off-by: Chen Hanxiao <chenhanxiao(a)gmail.com>
---
tools/virsh-domain.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 7194153..b96b8fd 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -8254,9 +8254,14 @@ static int getSignalNumber(vshControl *ctl, const char *signame)
for (i = 0; signame[i]; i++)
lower[i] = c_tolower(signame[i]);
+ if (STRPREFIX(lower, "-"))
+ lower += 1;
+
if (virStrToLong_i(lower, NULL, 10, &signum) >= 0)
goto cleanup;
+ lower = tmp;
+
if (STRPREFIX(lower, "sig_"))
lower += 4;
else if (STRPREFIX(lower, "sig"))
--
1.8.3.1
8 years, 2 months
[libvirt] qemu - how add -object when no numa topology
by Safka, JaroslavX
Hi guys,
I’m trying to figure out how to generate this arg line:
“-object memory-backend-file,id=ram,mem-path=/var/lib/libvirt/qemu/,share=yes,size=14336 -numa node, memdev=ram”
without numa.
I see there are two functions which are capable of building backends:
“qemuBuildNumaArgStr” and “qemuBuildMemoryDeviceCommandLine”
The “qemuBuildNumaArgStr” I’m already using for creating backend+object when numa is enabled.
But I’m not sure how to “activate” code inside “qemuBuildMemoryDeviceCommandLine” when numa is disabled.
I found there must be (in xml) record “devices/memory” to create record def->mems. But I do not know if I should add this element into xml
or I should allocate this structure by myself. Or create duplicated function, and create arg string with “-object …” inside on my own.
This all is needed for new feature and new xml elements:
(hugepages will not be used)
<memoryBacking>
<source type='file' path='/path/to/qemu'/>
<access mode='shared'/>
<allocation mode='immediate'/>
</memoryBacking>
Many thanks for any tips or help ☺
Best regards
Jarek
PS: I’m quite new in the libvirt code/community
--------------------------------------------------------------
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263
This e-mail and any attachments may contain confidential material for the sole
use of the intended recipient(s). Any review or distribution by others is
strictly prohibited. If you are not the intended recipient, please contact the
sender and delete all copies.
8 years, 2 months
[libvirt] [PATCH 0/8] cleanup and regenerate data for qemuhelptest
by Pavel Hrdina
Pavel Hrdina (8):
qemuhelptest: remove downstream test data
qemuhelptest: regenerate data for qemu-0.12.1
qemuhelptest: regenerate data for qemu-1.0
qemuhelptest: regenerate data for qemu-1.1.0
qemuhelptest: regenerate data for qemu-1.2.0
qemuhelptest: regenerate data for qemu-kvm-0.12.3
qemuhelptest: regenerate data for qemu-kvm-0.13.0
qemuhelptest: regenerate data for qemu-kvm-1.2.0
tests/qemuhelpdata/qemu-0.12.1 | 7 +-
tests/qemuhelpdata/qemu-0.12.1-device | 62 ++++++
tests/qemuhelpdata/qemu-1.0 | 1 +
tests/qemuhelpdata/qemu-1.0-device | 146 ++++++-------
tests/qemuhelpdata/qemu-1.1.0 | 1 +
tests/qemuhelpdata/qemu-1.1.0-device | 20 +-
tests/qemuhelpdata/qemu-1.2.0 | 1 +
tests/qemuhelpdata/qemu-1.2.0-device | 226 --------------------
tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel60 | 227 --------------------
tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel60-device | 57 -----
tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel61 | 229 --------------------
tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel61-device | 99 ---------
tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel62-beta | 230 ---------------------
.../qemu-kvm-0.12.1.2-rhel62-beta-device | 120 -----------
tests/qemuhelpdata/qemu-kvm-0.12.3 | 7 +-
tests/qemuhelpdata/qemu-kvm-0.12.3-device | 63 ++++++
tests/qemuhelpdata/qemu-kvm-0.13.0 | 1 -
tests/qemuhelpdata/qemu-kvm-0.13.0-device | 4 +-
tests/qemuhelpdata/qemu-kvm-1.2.0 | 1 +
tests/qemuhelptest.c | 150 ++------------
20 files changed, 234 insertions(+), 1418 deletions(-)
delete mode 100644 tests/qemuhelpdata/qemu-1.2.0-device
delete mode 100644 tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel60
delete mode 100644 tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel60-device
delete mode 100644 tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel61
delete mode 100644 tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel61-device
delete mode 100644 tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel62-beta
delete mode 100644 tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel62-beta-device
--
2.10.0
8 years, 2 months
[libvirt] [PATCH v2 0/3] pass the path of compress prog directly
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)gmail.com>
This series will pass the path of compress programe
directly to functions such as doCoreDump, qemuDomainSaveInternal, etc.
this can avoid one extra virFindFileInPath call in during virExec.
Also reduce code duplication by macros.
Chen Hanxiao (3):
qemu_driver: pass path of compress prog directly
qemu_driver: simplify compress prog check by macros
qemu_driver: pass path of compress prog directly to doCoreDump
src/qemu/qemu_driver.c | 242 ++++++++++++++++++++++++++-----------------------
1 file changed, 128 insertions(+), 114 deletions(-)
--
1.8.3.1
8 years, 2 months
[libvirt] [PATCH 0/7] Pass the path of compress program (redo)
by John Ferlan
Rather than try to describe what I was thinking about for the passing
the compress program directly series from Chen Hanxiao:
http://www.redhat.com/archives/libvir-list/2016-September/msg00677.html
and
http://www.redhat.com/archives/libvir-list/2016-August/msg01237.html
I took the liberty of creating my own set of patches which should end
in the more or less same result.
The primary benefit is not calling virFileInPath twice since we already
get it at least once for the various compressed program callers, let's
pass what we originally found.
John Ferlan (7):
qemu: Move getCompressionType
qemu: Adjust doCoreDump to call getCompressionType
qemu: Introduce helper qemuGetCompressionProgram
qemu: Remove getCompressionType
qemu: Use qemuGetCompressionProgram for error paths
qemu: Remove qemuCompressProgramAvailable
qemu: Get/return compressedpath program
src/qemu/qemu_driver.c | 235 +++++++++++++++++++++++--------------------------
1 file changed, 111 insertions(+), 124 deletions(-)
--
2.7.4
8 years, 2 months
[libvirt] ANNOUNCE: ruby-libvirt 0.7.0
by Chris Lalancette
I'm pleased to release ruby-libvirt 0.7.0. ruby-libvirt is a ruby wrapper
around the libvirt API. The changelog between 0.6.0 and 0.7.0 is:
* Fix network lease API to allow arguments that libvirt allows
* Implement VIRT_STORAGE_POOL_CREATE flags
* Implement more VIR_STORAGE_VOL flags
* Implement VIR_DOMAIN_QEMU_AGENT_COMMAND_SHUTDOWN
* Implement virDomainDefineXMLFlags
* Implement virDomainRename
* Implement virDomainSetUserPassword
* Implement VIR_DOMAIN_TIME_SYNC
* Fix the return value from virStreamSourceFunc so volume upload works
Version 0.7.0 is available from http://libvirt.org/ruby:
Tarball: http://libvirt.org/ruby/download/ruby-libvirt-0.7.0.tgz
Gem: http://libvirt.org/ruby/download/ruby-libvirt-0.7.0.gem
It is also available from rubygems.org; to get the latest version, run:
$ gem install ruby-libvirt
Packages for it are also built for Fedora, and will be released shortly.
As usual, if you run into questions, problems, or bugs, please feel free to
mail me (clalancette at gmail.com) and the libvirt mailing list.
Thanks to those who contributed to this release.
8 years, 2 months
[libvirt] [PATCH] qemu: Fix improper indention
by John Ferlan
Commit id 'ce61c164' indented wrong - not sure how I did that...
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
Pushed under the trivial rule
src/qemu/qemu_command.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f6d26b0..1ac0fa1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5041,20 +5041,20 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
telnet ? ",telnet" : "",
dev->data.tcp.listen ? ",server,nowait" : "");
- if (cfg->chardevTLS) {
- char *objalias = NULL;
+ if (cfg->chardevTLS) {
+ char *objalias = NULL;
- if (qemuBuildTLSx509CommandLine(cmd, cfg->chardevTLSx509certdir,
- dev->data.tcp.listen,
- cfg->chardevTLSx509verify,
- alias, qemuCaps) < 0)
- goto error;
+ if (qemuBuildTLSx509CommandLine(cmd, cfg->chardevTLSx509certdir,
+ dev->data.tcp.listen,
+ cfg->chardevTLSx509verify,
+ alias, qemuCaps) < 0)
+ goto error;
- if (!(objalias = qemuAliasTLSObjFromChardevAlias(alias)))
- goto error;
- virBufferAsprintf(&buf, ",tls-creds=%s", objalias);
- VIR_FREE(objalias);
- }
+ if (!(objalias = qemuAliasTLSObjFromChardevAlias(alias)))
+ goto error;
+ virBufferAsprintf(&buf, ",tls-creds=%s", objalias);
+ VIR_FREE(objalias);
+ }
break;
case VIR_DOMAIN_CHR_TYPE_UNIX:
--
2.7.4
8 years, 2 months
[libvirt] [PATCH] Fix Multiple Typos
by Nitesh Konkar
Signed-off-by: Nitesh Konkar <nitkon12(a)linux.vnet.ibm.com>
---
src/conf/domain_conf.c | 4 ++--
src/conf/domain_conf.h | 2 +-
src/conf/storage_conf.c | 2 +-
src/esx/esx_driver.c | 4 ++--
src/interface/interface_backend_udev.c | 2 +-
5 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5fede3d..dd34cec 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14165,7 +14165,7 @@ void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
virDomainControllerDefPtr controller)
{
int idx;
- /* Tenatively plan to insert controller at the end. */
+ /* Tentatively plan to insert controller at the end. */
int insertAt = -1;
virDomainControllerDefPtr current = NULL;
@@ -19847,7 +19847,7 @@ virDomainDiskBlockIoDefFormat(virBufferPtr buf,
/* virDomainSourceDefFormatSeclabel:
*
- * This function automaticaly closes the <source> element and formats any
+ * This function automatically closes the <source> element and formats any
* possible seclabels.
*/
static void
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index d4a84c3..ce90c27 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -300,7 +300,7 @@ typedef enum {
/* the backend driver used for PCI hostdev devices */
typedef enum {
- VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT, /* detect automaticaly, prefer VFIO */
+ VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT, /* detect automatically, prefer VFIO */
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM, /* force legacy kvm style */
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO, /* force vfio */
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN, /* force legacy xen style, use pciback */
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 05a1a49..7e7bb72 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -2476,7 +2476,7 @@ virStoragePoolSourceFindDuplicate(virConnectPtr conn,
if (def->type != pool->def->type)
continue;
- /* Don't mach against ourself if re-defining existing pool ! */
+ /* Don't match against ourself if re-defining existing pool ! */
if (STREQ(pool->def->name, def->name))
continue;
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 3d90b69..5ce98b3 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -78,7 +78,7 @@ esxFreePrivate(esxPrivate **priv)
/*
* Parse a file name from a .vmx file and convert it to datastore path format
- * if possbile. A .vmx file can contain file names in various formats:
+ * if possible. A .vmx file can contain file names in various formats:
*
* - A single name referencing a file in the same directory as the .vmx file:
*
@@ -969,7 +969,7 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
STRNEQ(vCenterIPAddress, potentialVCenterIPAddress)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("This host is managed by a vCenter with IP "
- "address %s, but a mismachting vCenter '%s' "
+ "address %s, but a mismatching vCenter '%s' "
"(%s) has been specified"),
potentialVCenterIPAddress, priv->parsedUri->vCenter,
vCenterIPAddress);
diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c
index 27a772d..5d0fc64 100644
--- a/src/interface/interface_backend_udev.c
+++ b/src/interface/interface_backend_udev.c
@@ -884,7 +884,7 @@ udevGetIfaceDefBridge(struct udev *udev,
goto error;
ifacedef->data.bridge.nbItf = member_count;
- /* Get the interface defintions for each member of the bridge */
+ /* Get the interface definitions for each member of the bridge */
for (i = 0; i < member_count; i++) {
ifacedef->data.bridge.itf[i] =
udevGetIfaceDef(udev, member_list[i]->d_name);
--
2.1.0
8 years, 2 months