[libvirt] [PATCH] vsh: print help more often
by Michal Privoznik
So, consider following scenario:
virsh # migrate --help
In this case migrate help is printed out. So far so good.
However, you start writing this long migrate command (I bet you
know the arguments there can get quite long), but then, at some
point you need to print out the help. Something like this:
virsh # migrate --copy-storage-all --migrate-disks --help
In this specific case you just want to see the format that
--migrate-disks accepts. So you append --help and expect help to
be printed out. Well, it will not, because "--help" is taken as
data to --migrate-disks. Therefore we will get this error
instead:
virsh # migrate --copy-storage-all --migrate-disks --help
error: command 'migrate' requires <domain> option
error: command 'migrate' requires <desturi> option
Teach our parsing code, that --help may occur even in argument
data, and therefore anywhere on the command line.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tools/vsh.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/vsh.c b/tools/vsh.c
index e57c324..d67f5de 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -1415,7 +1415,8 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser)
/* if we encountered --help, replace parsed command with
* 'help <cmdname>' */
for (tmpopt = first; tmpopt; tmpopt = tmpopt->next) {
- if (STRNEQ(tmpopt->def->name, "help"))
+ if (STRNEQ(tmpopt->def->name, "help") &&
+ STRNEQ_NULLABLE(tmpopt->data, "--help"))
continue;
const vshCmdDef *help = vshCmddefSearch("help");
--
2.4.10
9 years, 2 months
[libvirt] [PATCH] virsh: fix no error when pass a count <= 0 to setvcpus
by Luyao Huang
https://bugzilla.redhat.com/show_bug.cgi?id=1248277
When count <= 0, the client exit without set an error.
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
tools/virsh-domain.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index f7edeeb..b6da684 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -6744,8 +6744,12 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false;
- if (vshCommandOptInt(ctl, cmd, "count", &count) < 0 || count <= 0)
+ if (vshCommandOptInt(ctl, cmd, "count", &count) < 0)
goto cleanup;
+ if (count <= 0) {
+ vshError(ctl, _("Invalid value '%d' for number of virtual CPUs"), count);
+ goto cleanup;
+ }
/* none of the options were specified */
if (!current && flags == 0) {
--
1.8.3.1
9 years, 2 months
[libvirt] [PATCH] conf: fix set the wrong fromconfig when specify addr in config
by Luyao Huang
https://bugzilla.redhat.com/show_bug.cgi?id=1238338#c6
If the user already specify address in xml, we will set the
wrong $fromConfig, which will make libvirt output a wrong error
message and make hot-plug fail when hot-plug a pci device (see
commit 1e15be1 and 9a12b6c).
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
src/conf/domain_addr.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index ca5803e..49769f7 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -376,6 +376,14 @@ virDomainPCIAddressReserveSlot(virDomainPCIAddressSetPtr addrs,
return virDomainPCIAddressReserveAddr(addrs, addr, flags, true, false);
}
+static int
+virDomainPCIAddressReserveSlotFromConfig(virDomainPCIAddressSetPtr addrs,
+ virDevicePCIAddressPtr addr,
+ virDomainPCIConnectFlags flags)
+{
+ return virDomainPCIAddressReserveAddr(addrs, addr, flags, true, true);
+}
+
int
virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs,
virDomainDeviceInfoPtr dev)
@@ -408,7 +416,8 @@ virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs,
addrStr, flags, true))
goto cleanup;
- ret = virDomainPCIAddressReserveSlot(addrs, &dev->addr.pci, flags);
+ ret = virDomainPCIAddressReserveSlotFromConfig(addrs,
+ &dev->addr.pci, flags);
} else {
ret = virDomainPCIAddressReserveNextSlot(addrs, dev, flags);
}
--
1.8.3.1
9 years, 2 months
[libvirt] [PATCH 00/12] Have 'buildVol' callers to clean up after themselves
by John Ferlan
NOTE: Although one may consider this a v2 of :
http://www.redhat.com/archives/libvir-list/2015-October/msg00196.html
It's more tackling the same problem a different way...
Rather than pass a 'created' boolean around, this series investigated
each of the 'createVol' and 'buildVol' paths in order to make more
conscious decisions related to whether or not a volume was created and
to handle failures after creation by deleting the volume/file.
The end result is that all the 'buildVol' backends will now delete
the volume they created on error paths leaving the storage driver to
only need to remove the volume from the pool.
As such this series will also revert a prior patch in this area.
John Ferlan (12):
storage: Remove duplicitous refreshVol in RBD buildVol
storage: Remove duplicitous refreshVol in Sheepdog buildVol
storage: Fix a resource leak in storageVolCreateXML
storage: Track successful creation of LV for removal
storage: On error unlink created file in virFileOpen{As|Forked}
storage: On error rmdir created directory in virDirCreate[NoFork]
storage: Rework error paths for virStorageBackendCreateExecCommand
storage: Cleanup failures virStorageBackendCreateExecCommand
storage: Cleanup failures in virStorageBackendCreateRaw
storage: Pull volume removal from pool in storageVolDeleteInternal
Revert "storage: Prior to creating a volume, refresh the pool"
storage: On 'buildVol' failure don't delete the volume
src/storage/storage_backend.c | 38 +++++++++++++++++------
src/storage/storage_backend_logical.c | 5 ++-
src/storage/storage_backend_rbd.c | 3 --
src/storage/storage_backend_sheepdog.c | 5 +--
src/storage/storage_driver.c | 56 ++++++++++++++++++++--------------
src/util/virfile.c | 22 ++++++++++++-
6 files changed, 88 insertions(+), 41 deletions(-)
--
2.1.0
9 years, 2 months
[libvirt] [PATCH v2] lxc: fuse mount for /proc/cpuinfo
by Cédric Bosdonnat
We already have a fuse mount to reflect the cgroup memory restrictions
in the container. This commit adds the same for the number of available
CPUs. Only the CPUs listed by virProcessGetAffinity are shown in the
container's cpuinfo.
---
src/lxc/lxc_container.c | 42 ++++++++++++-------
src/lxc/lxc_fuse.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 133 insertions(+), 15 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index a433552..7ae13a8 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1055,24 +1055,38 @@ static int lxcContainerMountProcFuse(virDomainDefPtr def,
const char *stateDir)
{
int ret;
- char *meminfo_path = NULL;
+ char *src_path = NULL;
+ char *dst_path = NULL;
+ const char *paths[] = {"meminfo", "cpuinfo"};
+ size_t i;
- VIR_DEBUG("Mount /proc/meminfo stateDir=%s", stateDir);
+ for (i = 0; i < 2; i++) {
+ VIR_DEBUG("Mount /proc/%s stateDir=%s", paths[i], stateDir);
+
+ if ((ret = virAsprintf(&src_path,
+ "/.oldroot/%s/%s.fuse/%s",
+ stateDir,
+ def->name,
+ paths[i])) < 0)
+ return ret;
+
+ if ((ret = virAsprintf(&dst_path,
+ "/proc/%s",
+ paths[i])) < 0) {
+ VIR_FREE(src_path);
+ return ret;
+ }
- if ((ret = virAsprintf(&meminfo_path,
- "/.oldroot/%s/%s.fuse/meminfo",
- stateDir,
- def->name)) < 0)
- return ret;
+ if ((ret = mount(src_path, dst_path,
+ NULL, MS_BIND, NULL)) < 0) {
+ virReportSystemError(errno,
+ _("Failed to mount %s on %s"),
+ src_path, dst_path);
+ }
- if ((ret = mount(meminfo_path, "/proc/meminfo",
- NULL, MS_BIND, NULL)) < 0) {
- virReportSystemError(errno,
- _("Failed to mount %s on /proc/meminfo"),
- meminfo_path);
+ VIR_FREE(src_path);
+ VIR_FREE(dst_path);
}
-
- VIR_FREE(meminfo_path);
return ret;
}
#else
diff --git a/src/lxc/lxc_fuse.c b/src/lxc/lxc_fuse.c
index 34a69cc..0d60434 100644
--- a/src/lxc/lxc_fuse.c
+++ b/src/lxc/lxc_fuse.c
@@ -42,6 +42,58 @@
#if WITH_FUSE
static const char *fuse_meminfo_path = "/meminfo";
+static const char *fuse_cpuinfo_path = "/cpuinfo";
+
+static virBufferPtr lxcProcComputeCpuinfo(void) {
+ FILE *fd = NULL;
+ char *line = NULL;
+ size_t n;
+ bool writeProc = false;
+ virBuffer buffer = VIR_BUFFER_INITIALIZER;
+ virBufferPtr new_cpuinfo = &buffer;
+ pid_t pid;
+ virBitmapPtr cpuAffinity = NULL;
+
+ fd = fopen("/proc/cpuinfo", "r");
+ if (fd == NULL) {
+ virReportSystemError(errno, "%s", _("Cannot open /proc/cpuinfo"));
+ goto error;
+ }
+
+ pid = getpid();
+ if (!(cpuAffinity = virProcessGetAffinity(pid)))
+ goto error;
+
+ while (getline(&line, &n, fd) > 0) {
+ if (STRPREFIX(line, "processor\t:")) {
+ unsigned long cpuid = 0;
+ char *suffix = NULL;
+ if (virStrToLong_ul(line + 12, &suffix, 10, &cpuid) < 0)
+ goto error;
+
+ if (virBitmapGetBit(cpuAffinity, cpuid, &writeProc) < 0)
+ goto error;
+ }
+
+ if (writeProc) {
+ virBufferAdd(new_cpuinfo, line, -1);
+
+ if (virBufferCheckError(new_cpuinfo) < 0)
+ goto error;
+ }
+ }
+
+ cleanup:
+ VIR_FREE(line);
+ VIR_FORCE_FCLOSE(fd);
+ virBitmapFree(cpuAffinity);
+ return new_cpuinfo;
+
+ error:
+ virBufferFreeAndReset(new_cpuinfo);
+ new_cpuinfo = NULL;
+ goto cleanup;
+}
static int lxcProcGetattr(const char *path, struct stat *stbuf)
{
@@ -50,6 +102,7 @@ static int lxcProcGetattr(const char *path, struct stat *stbuf)
struct stat sb;
struct fuse_context *context = fuse_get_context();
virDomainDefPtr def = (virDomainDefPtr)context->private_data;
+ virBufferPtr cpuinfo = NULL;
memset(stbuf, 0, sizeof(struct stat));
if (virAsprintf(&mempath, "/proc/%s", path) < 0)
@@ -76,12 +129,36 @@ static int lxcProcGetattr(const char *path, struct stat *stbuf)
stbuf->st_atime = sb.st_atime;
stbuf->st_ctime = sb.st_ctime;
stbuf->st_mtime = sb.st_mtime;
+ } else if (STREQ(path, fuse_cpuinfo_path)) {
+ if (!(cpuinfo = lxcProcComputeCpuinfo())) {
+ res = -EIO;
+ goto cleanup;
+ }
+
+ if (stat(mempath, &sb) < 0) {
+ res = -errno;
+ goto cleanup;
+ }
+
+ stbuf->st_uid = def->idmap.uidmap ? def->idmap.uidmap[0].target : 0;
+ stbuf->st_gid = def->idmap.gidmap ? def->idmap.gidmap[0].target : 0;
+ stbuf->st_mode = sb.st_mode;
+ stbuf->st_nlink = 1;
+ stbuf->st_blksize = sb.st_blksize;
+ stbuf->st_size = virBufferUse(cpuinfo);
+ stbuf->st_blocks = stbuf->st_size / 512;
+ if (stbuf->st_size % 512 != 0)
+ stbuf->st_blocks++;
+ stbuf->st_atime = sb.st_atime;
+ stbuf->st_ctime = sb.st_ctime;
+ stbuf->st_mtime = sb.st_mtime;
} else {
res = -ENOENT;
}
cleanup:
VIR_FREE(mempath);
+ virBufferFreeAndReset(cpuinfo);
return res;
}
@@ -96,6 +173,7 @@ static int lxcProcReaddir(const char *path, void *buf,
filler(buf, ".", NULL, 0);
filler(buf, "..", NULL, 0);
filler(buf, fuse_meminfo_path + 1, NULL, 0);
+ filler(buf, fuse_cpuinfo_path + 1, NULL, 0);
return 0;
}
@@ -103,7 +181,8 @@ static int lxcProcReaddir(const char *path, void *buf,
static int lxcProcOpen(const char *path ATTRIBUTE_UNUSED,
struct fuse_file_info *fi ATTRIBUTE_UNUSED)
{
- if (!STREQ(path, fuse_meminfo_path))
+ if (!STREQ(path, fuse_meminfo_path) &&
+ !STREQ(path, fuse_cpuinfo_path))
return -ENOENT;
if ((fi->flags & 3) != O_RDONLY)
@@ -234,6 +313,28 @@ static int lxcProcReadMeminfo(char *hostpath, virDomainDefPtr def,
return res;
}
+static int lxcProcReadCpuinfo(char *buf, size_t size, off_t offset)
+{
+ virBufferPtr new_cpuinfo = lxcProcComputeCpuinfo();
+ int new_size = -1;
+ int copied = -1;
+
+ if (!new_cpuinfo)
+ goto error;
+
+ copied = size;
+ new_size = virBufferUse(new_cpuinfo);
+
+ if ((new_size - offset) < size)
+ copied = new_size - offset;
+
+ memcpy(buf, virBufferCurrentContent(new_cpuinfo) + offset, copied);
+
+ error:
+ virBufferFreeAndReset(new_cpuinfo);
+ return copied;
+}
+
static int lxcProcRead(const char *path ATTRIBUTE_UNUSED,
char *buf ATTRIBUTE_UNUSED,
size_t size ATTRIBUTE_UNUSED,
@@ -254,6 +355,9 @@ static int lxcProcRead(const char *path ATTRIBUTE_UNUSED,
if (STREQ(path, fuse_meminfo_path)) {
if ((res = lxcProcReadMeminfo(hostpath, def, buf, size, offset)) < 0)
res = lxcProcHostRead(hostpath, buf, size, offset);
+ } else if (STREQ(path, fuse_cpuinfo_path)) {
+ if ((res = lxcProcReadCpuinfo(buf, size, offset)) < 0)
+ res = lxcProcHostRead(hostpath, buf, size, offset);
}
VIR_FREE(hostpath);
--
2.1.4
9 years, 2 months
[libvirt] [PATCH 0/3] NEWS: Split releases by year
by Andrea Bolognani
As agreed, I've followed up with the cleanups by splitting
the huge news.html.in file into separate, smaller files,
one per year.
Along with the split I've also included a fixed XSLT
stylesheet so that we can start shipping a meaningful
NEWS file again.
Cheers.
Andrea Bolognani (3):
NEWS: Split releases by year (2005-2011)
NEWS: Split releases by year (2012-2015)
NEWS: Fix XSLT stylesheet
docs/news-2005.html.in | 28 +
docs/news-2006.html.in | 354 +
docs/news-2007.html.in | 534 ++
docs/news-2008.html.in | 580 ++
docs/news-2009.html.in | 1603 ++++
docs/news-2010.html.in | 2218 ++++++
docs/news-2011.html.in | 3314 +++++++++
docs/news-2012.html.in | 3012 ++++++++
docs/news-2013.html.in | 3675 ++++++++++
docs/news-2014.html.in | 3418 +++++++++
docs/news.html.in | 18544 +----------------------------------------------
docs/news.xsl | 30 +-
12 files changed, 18759 insertions(+), 18551 deletions(-)
create mode 100644 docs/news-2005.html.in
create mode 100644 docs/news-2006.html.in
create mode 100644 docs/news-2007.html.in
create mode 100644 docs/news-2008.html.in
create mode 100644 docs/news-2009.html.in
create mode 100644 docs/news-2010.html.in
create mode 100644 docs/news-2011.html.in
create mode 100644 docs/news-2012.html.in
create mode 100644 docs/news-2013.html.in
create mode 100644 docs/news-2014.html.in
--
2.4.3
9 years, 2 months
[libvirt] [PATCH 1/2] Prefer STREQ and STRNEQ
by Ishmanpreet Khera
use STRNEQ instead of !STREQ to remove inconsistency.
Signed-off-by: Ishmanpreet Kaur Khera <khera.ishman(a)gmail.com>
---
src/bhyve/bhyve_driver.c | 2 +-
src/conf/network_conf.c | 4 ++--
src/conf/nwfilter_conf.c | 2 +-
src/conf/nwfilter_params.c | 2 +-
src/conf/storage_conf.c | 2 +-
src/lxc/lxc_fuse.c | 4 ++--
src/openvz/openvz_driver.c | 2 +-
src/qemu/qemu_command.c | 6 +++---
src/qemu/qemu_domain.c | 2 +-
src/qemu/qemu_hotplug.c | 2 +-
src/security/security_manager.c | 2 +-
src/security/security_selinux.c | 12 ++++++------
src/storage/storage_backend_logical.c | 2 +-
src/util/virfile.c | 2 +-
src/util/virsystemd.c | 2 +-
src/vz/vz_driver.c | 2 +-
src/vz/vz_sdk.c | 2 +-
src/xen/xend_internal.c | 2 +-
src/xenconfig/xen_sxpr.c | 2 +-
tests/commandtest.c | 10 +++++-----
tests/securityselinuxlabeltest.c | 2 +-
tests/virauthconfigtest.c | 2 +-
tests/virbitmaptest.c | 12 ++++++------
tests/vircgrouptest.c | 2 +-
tests/virkeyfiletest.c | 8 ++++----
tests/virnetsockettest.c | 2 +-
tests/virtypedparamtest.c | 2 +-
tests/viruritest.c | 16 ++++++++--------
28 files changed, 56 insertions(+), 56 deletions(-)
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index d44cf2c..e5d56e9 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -197,7 +197,7 @@ bhyveConnectOpen(virConnectPtr conn,
if (conn->uri->server)
return VIR_DRV_OPEN_DECLINED;
- if (!STREQ_NULLABLE(conn->uri->path, "/system")) {
+ if (STRNEQ_NULLABLE(conn->uri->path, "/system")) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected bhyve URI path '%s', try
bhyve:///system"),
conn->uri->path);
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index c1cbd76..0ffb325 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -3042,7 +3042,7 @@ virNetworkLoadState(virNetworkObjListPtr nets,
if (!(def = virNetworkDefParseXML(ctxt)))
goto error;
- if (!STREQ(name, def->name)) {
+ if (STRNEQ(name, def->name)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Network config filename '%s'"
" does not match network name '%s'"),
@@ -3152,7 +3152,7 @@ virNetworkObjPtr
virNetworkLoadConfig(virNetworkObjListPtr nets,
if (!(def = virNetworkDefParseFile(configFile)))
goto error;
- if (!STREQ(name, def->name)) {
+ if (STRNEQ(name, def->name)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Network config filename '%s'"
" does not match network name '%s'"),
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index aed82ad..08c4264 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -3082,7 +3082,7 @@ virNWFilterObjAssignDef(virNWFilterObjListPtr
nwfilters,
nwfilter = virNWFilterObjFindByUUID(nwfilters, def->uuid);
if (nwfilter) {
- if (!STREQ(def->name, nwfilter->def->name)) {
+ if (STRNEQ(def->name, nwfilter->def->name)) {
virReportError(VIR_ERR_OPERATION_FAILED,
_("filter with same UUID but different name "
"('%s') already exists"),
diff --git a/src/conf/nwfilter_params.c b/src/conf/nwfilter_params.c
index 0ac8baa..b6c6e78 100644
--- a/src/conf/nwfilter_params.c
+++ b/src/conf/nwfilter_params.c
@@ -444,7 +444,7 @@
virNWFilterVarCombIterEntryAreUniqueEntries(virNWFilterVarCombIterEntryPtr
cie,
/* should never occur to step on a NULL here */
return true;
}
- if (!STREQ(virNWFilterVarValueGetNthValue(tmp,
cie->curValue),
+ if (STRNEQ(virNWFilterVarValueGetNthValue(tmp,
cie->curValue),
virNWFilterVarValueGetNthValue(tmp, i))) {
isSame = false;
break;
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 9dae1a3..9b8abea 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1873,7 +1873,7 @@ virStoragePoolLoadState(virStoragePoolObjListPtr
pools,
if (!(def = virStoragePoolDefParseXML(ctxt)))
goto error;
- if (!STREQ(name, def->name)) {
+ if (STRNEQ(name, def->name)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Storage pool state file '%s' does not match "
"pool name '%s'"),
diff --git a/src/lxc/lxc_fuse.c b/src/lxc/lxc_fuse.c
index 34a69cc..862dca3 100644
--- a/src/lxc/lxc_fuse.c
+++ b/src/lxc/lxc_fuse.c
@@ -90,7 +90,7 @@ static int lxcProcReaddir(const char *path, void *buf,
off_t offset ATTRIBUTE_UNUSED,
struct fuse_file_info *fi ATTRIBUTE_UNUSED)
{
- if (!STREQ(path, "/"))
+ if (STRNEQ(path, "/"))
return -ENOENT;
filler(buf, ".", NULL, 0);
@@ -103,7 +103,7 @@ static int lxcProcReaddir(const char *path, void *buf,
static int lxcProcOpen(const char *path ATTRIBUTE_UNUSED,
struct fuse_file_info *fi ATTRIBUTE_UNUSED)
{
- if (!STREQ(path, fuse_meminfo_path))
+ if (STRNEQ(path, fuse_meminfo_path))
return -ENOENT;
if ((fi->flags & 3) != O_RDONLY)
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index d78e2f5..b8c0f50 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -2048,7 +2048,7 @@ openvzUpdateDevice(virDomainDefPtr vmdef,
cur = vmdef->fss[pos];
/* We only allow updating the quota */
- if (!STREQ(cur->src, fs->src)
+ if (STRNEQ(cur->src, fs->src)
|| cur->type != fs->type
|| cur->accessmode != fs->accessmode
|| cur->wrpolicy != fs->wrpolicy
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f727d0b..d664bf1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3008,7 +3008,7 @@ qemuParseDriveURIString(virDomainDiskDefPtr def,
virURIPtr uri,
if (transp)
*transp++ = 0;
- if (!STREQ(uri->scheme, scheme)) {
+ if (STRNEQ(uri->scheme, scheme)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid transport/scheme '%s'"), uri->scheme);
goto error;
@@ -10030,7 +10030,7 @@ qemuBuildCommandLine(virConnectPtr conn,
virDomainDiskDefPtr disk = def->disks[i];
if (disk->src->driverName != NULL &&
- !STREQ(disk->src->driverName, "qemu")) {
+ STRNEQ(disk->src->driverName, "qemu")) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported driver name '%s' for disk '%s'"),
disk->src->driverName, disk->src->path);
@@ -12728,7 +12728,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
if (VIR_STRDUP(model, tokens[i]) < 0)
goto cleanup;
- if (!STREQ(model, "qemu32") && !STREQ(model, "qemu64")) {
+ if (STRNEQ(model, "qemu32") && STRNEQ(model, "qemu64")) {
if (!(cpu = qemuInitGuestCPU(dom)))
goto cleanup;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index bdc0e67..890d8ed 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1061,7 +1061,7 @@ qemuDomainDefPostParse(virDomainDefPtr def,
if (!STRPREFIX(def->os.machine, "pc-0.") &&
!STRPREFIX(def->os.machine, "pc-1.") &&
!STRPREFIX(def->os.machine, "pc-i440") &&
- !STREQ(def->os.machine, "pc") &&
+ STRNEQ(def->os.machine, "pc") &&
!STRPREFIX(def->os.machine, "rhel"))
break;
addPCIRoot = true;
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index afc5408..470ab6a 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -783,7 +783,7 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
const char *driverName = virDomainDiskGetDriver(disk);
const char *src = virDomainDiskGetSource(disk);
- if (driverName && !STREQ(driverName, "qemu")) {
+ if (driverName && STRNEQ(driverName, "qemu")) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported driver name '%s' for disk '%s'"),
driverName, src);
diff --git a/src/security/security_manager.c
b/src/security/security_manager.c
index 5b05a47..07a0522 100644
--- a/src/security/security_manager.c
+++ b/src/security/security_manager.c
@@ -130,7 +130,7 @@ int
virSecurityManagerStackAddNested(virSecurityManagerPtr stack,
virSecurityManagerPtr nested)
{
- if (!STREQ("stack", stack->drv->name))
+ if (STRNEQ("stack", stack->drv->name))
return -1;
return virSecurityStackAddNested(stack, nested);
}
diff --git a/src/security/security_selinux.c
b/src/security/security_selinux.c
index c2464c2..80b0886 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -2061,7 +2061,7 @@
virSecuritySELinuxSecurityVerify(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
if (secdef == NULL)
return 0;
- if (!STREQ(SECURITY_SELINUX_NAME, secdef->model)) {
+ if (STRNEQ(SECURITY_SELINUX_NAME, secdef->model)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("security label driver mismatch: "
"'%s' model configured for domain, but "
@@ -2092,7 +2092,7 @@
virSecuritySELinuxSetSecurityProcessLabel(virSecurityManagerPtr mgr
ATTRIBUTE_UN
return 0;
VIR_DEBUG("label=%s", secdef->label);
- if (!STREQ(SECURITY_SELINUX_NAME, secdef->model)) {
+ if (STRNEQ(SECURITY_SELINUX_NAME, secdef->model)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("security label driver mismatch: "
"'%s' model configured for domain, but "
@@ -2126,7 +2126,7 @@
virSecuritySELinuxSetSecurityChildProcessLabel(virSecurityManagerPtr mgr
ATTRIBU
return 0;
VIR_DEBUG("label=%s", secdef->label);
- if (!STREQ(SECURITY_SELINUX_NAME, secdef->model)) {
+ if (STRNEQ(SECURITY_SELINUX_NAME, secdef->model)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("security label driver mismatch: "
"'%s' model configured for domain, but "
@@ -2155,7 +2155,7 @@
virSecuritySELinuxSetSecurityDaemonSocketLabel(virSecurityManagerPtr mgr
ATTRIBU
if (!secdef || !secdef->label)
return 0;
- if (!STREQ(SECURITY_SELINUX_NAME, secdef->model)) {
+ if (STRNEQ(SECURITY_SELINUX_NAME, secdef->model)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("security label driver mismatch: "
"'%s' model configured for domain, but "
@@ -2202,7 +2202,7 @@
virSecuritySELinuxSetSecuritySocketLabel(virSecurityManagerPtr mgr
ATTRIBUTE_UNU
if (!secdef || !secdef->label)
return 0;
- if (!STREQ(SECURITY_SELINUX_NAME, secdef->model)) {
+ if (STRNEQ(SECURITY_SELINUX_NAME, secdef->model)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("security label driver mismatch: "
"'%s' model configured for domain, but "
@@ -2240,7 +2240,7 @@
virSecuritySELinuxClearSecuritySocketLabel(virSecurityManagerPtr mgr
ATTRIBUTE_U
if (!secdef || !secdef->label)
return 0;
- if (!STREQ(SECURITY_SELINUX_NAME, secdef->model)) {
+ if (STRNEQ(SECURITY_SELINUX_NAME, secdef->model)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("security label driver mismatch: "
"'%s' model configured for domain, but "
diff --git a/src/storage/storage_backend_logical.c
b/src/storage/storage_backend_logical.c
index 070f2bd..90bfa58 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -147,7 +147,7 @@ virStorageBackendLogicalMakeVol(char **const groups,
* (lvs outputs "[$lvname_vorigin] for field "origin" if the
* lv is created with "--virtualsize").
*/
- if (groups[1] && !STREQ(groups[1], "") && (groups[1][0] != '[')) {
+ if (groups[1] && STRNEQ(groups[1], "") && (groups[1][0] != '[')) {
if (VIR_ALLOC(vol->target.backingStore) < 0)
goto cleanup;
diff --git a/src/util/virfile.c b/src/util/virfile.c
index a81f04c..33c7ff1 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -1008,7 +1008,7 @@ virFileStripSuffix(char *str, const char *suffix)
if (len < suffixlen)
return 0;
- if (!STREQ(str + len - suffixlen, suffix))
+ if (STRNEQ(str + len - suffixlen, suffix))
return 0;
str[len-suffixlen] = '\0';
diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
index 54c409d..1354b08 100644
--- a/src/util/virsystemd.c
+++ b/src/util/virsystemd.c
@@ -375,7 +375,7 @@ int virSystemdTerminateMachine(const char *name,
goto cleanup;
if (error.code == VIR_ERR_ERROR &&
- !STREQ_NULLABLE("org.freedesktop.machine1.NoSuchMachine",
+ STRNEQ_NULLABLE("org.freedesktop.machine1.NoSuchMachine",
error.str1)) {
virReportErrorObject(&error);
goto cleanup;
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index d0b4692..c4ba982 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -301,7 +301,7 @@ vzConnectOpen(virConnectPtr conn,
return VIR_DRV_OPEN_DECLINED;
/* From this point on, the connection is for us. */
- if (!STREQ_NULLABLE(conn->uri->path, "/system")) {
+ if (STRNEQ_NULLABLE(conn->uri->path, "/system")) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected Virtuozzo URI path '%s', try
vz:///system"),
conn->uri->path);
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 7a2afd6..d14c732 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -2026,7 +2026,7 @@ prlsdkCheckUnsupportedParams(PRL_HANDLE sdkdom,
virDomainDefPtr def)
}
} else {
if (def->os.nBootDevs != 0 ||
- !STREQ_NULLABLE(def->os.init, "/sbin/init") ||
+ STRNEQ_NULLABLE(def->os.init, "/sbin/init") ||
(def->os.initargv != NULL && def->os.initargv[0] != NULL)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index b81c0b7..62ce930 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -2552,7 +2552,7 @@ xenDaemonDomainSetAutostart(virConnectPtr conn,
if (autonode) {
const char *val = (autonode->u.s.car->kind == SEXPR_VALUE
? autonode->u.s.car->u.value : NULL);
- if (!val || (!STREQ(val, "ignore") && !STREQ(val, "start"))) {
+ if (!val || (STRNEQ(val, "ignore") && STRNEQ(val, "start"))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("unexpected value from on_xend_start"));
goto error;
diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c
index 033b0eb..7fc9c9d 100644
--- a/src/xenconfig/xen_sxpr.c
+++ b/src/xenconfig/xen_sxpr.c
@@ -2345,7 +2345,7 @@ xenFormatSxpr(virConnectPtr conn,
/* Only xend <= 3.0.2 wants cdrom config here */
if (xendConfigVersion != XEND_CONFIG_VERSION_3_0_2)
break;
- if (!STREQ(def->disks[i]->dst, "hdc") || !src)
+ if (STRNEQ(def->disks[i]->dst, "hdc") || !src)
break;
virBufferEscapeSexpr(&buf, "(cdrom '%s')", src);
diff --git a/tests/commandtest.c b/tests/commandtest.c
index f001a39..cf5f44a 100644
--- a/tests/commandtest.c
+++ b/tests/commandtest.c
@@ -516,7 +516,7 @@ static int test13(const void *unused ATTRIBUTE_UNUSED)
virCommandFree(cmd);
cmd = NULL;
- if (!STREQ(outactual, outexpect)) {
+ if (STRNEQ(outactual, outexpect)) {
virtTestDifference(stderr, outexpect, outactual);
goto cleanup;
}
@@ -580,15 +580,15 @@ static int test14(const void *unused ATTRIBUTE_UNUSED)
if (!jointactual)
goto cleanup;
- if (!STREQ(outactual, outexpect)) {
+ if (STRNEQ(outactual, outexpect)) {
virtTestDifference(stderr, outexpect, outactual);
goto cleanup;
}
- if (!STREQ(erractual, errexpect)) {
+ if (STRNEQ(erractual, errexpect)) {
virtTestDifference(stderr, errexpect, erractual);
goto cleanup;
}
- if (!STREQ(jointactual, jointexpect)) {
+ if (STRNEQ(jointactual, jointexpect)) {
virtTestDifference(stderr, jointexpect, jointactual);
goto cleanup;
}
@@ -666,7 +666,7 @@ static int test16(const void *unused ATTRIBUTE_UNUSED)
goto cleanup;
}
- if (!STREQ(outactual, outexpect)) {
+ if (STRNEQ(outactual, outexpect)) {
virtTestDifference(stderr, outexpect, outactual);
goto cleanup;
}
diff --git a/tests/securityselinuxlabeltest.c
b/tests/securityselinuxlabeltest.c
index 86660f4..c82b3f2 100644
--- a/tests/securityselinuxlabeltest.c
+++ b/tests/securityselinuxlabeltest.c
@@ -282,7 +282,7 @@ testSELinuxCheckLabels(testSELinuxFile *files, size_t
nfiles)
return -1;
}
}
- if (!STREQ_NULLABLE(files[i].context, ctx)) {
+ if (STRNEQ_NULLABLE(files[i].context, ctx)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"File %s context '%s' did not match epected
'%s'",
files[i].file, ctx, files[i].context);
diff --git a/tests/virauthconfigtest.c b/tests/virauthconfigtest.c
index d9e05fd..4c380b9 100644
--- a/tests/virauthconfigtest.c
+++ b/tests/virauthconfigtest.c
@@ -60,7 +60,7 @@ static int testAuthLookup(const void *args)
if (data->expect) {
if (!actual ||
- !STREQ(actual, data->expect)) {
+ STRNEQ(actual, data->expect)) {
VIR_WARN("Expected value '%s' for '%s' '%s' '%s', but got
'%s'",
data->expect, data->hostname,
data->service, data->credname,
diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c
index a6e9a38..8e458d2 100644
--- a/tests/virbitmaptest.c
+++ b/tests/virbitmaptest.c
@@ -355,7 +355,7 @@ test6(const void *v ATTRIBUTE_UNUSED)
if (!str)
goto error;
- if (!STREQ(str, ""))
+ if (STRNEQ(str, ""))
goto error;
VIR_FREE(str);
@@ -365,7 +365,7 @@ test6(const void *v ATTRIBUTE_UNUSED)
if (!str)
goto error;
- if (!STREQ(str, "0"))
+ if (STRNEQ(str, "0"))
goto error;
VIR_FREE(str);
@@ -376,7 +376,7 @@ test6(const void *v ATTRIBUTE_UNUSED)
if (!str)
goto error;
- if (!STREQ(str, "0,4-5"))
+ if (STRNEQ(str, "0,4-5"))
goto error;
VIR_FREE(str);
@@ -386,7 +386,7 @@ test6(const void *v ATTRIBUTE_UNUSED)
if (!str)
goto error;
- if (!STREQ(str, "0,4-6"))
+ if (STRNEQ(str, "0,4-6"))
goto error;
VIR_FREE(str);
@@ -399,7 +399,7 @@ test6(const void *v ATTRIBUTE_UNUSED)
if (!str)
goto error;
- if (!STREQ(str, "0,4-6,13-16"))
+ if (STRNEQ(str, "0,4-6,13-16"))
goto error;
VIR_FREE(str);
@@ -410,7 +410,7 @@ test6(const void *v ATTRIBUTE_UNUSED)
if (!str)
goto error;
- if (!STREQ(str, "0,4-6,13-16,62-63"))
+ if (STRNEQ(str, "0,4-6,13-16,62-63"))
goto error;
diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c
index 7a87640..731ecc4 100644
--- a/tests/vircgrouptest.c
+++ b/tests/vircgrouptest.c
@@ -662,7 +662,7 @@ static int testCgroupGetPercpuStats(const void *args
ATTRIBUTE_UNUSED)
}
for (i = 0; i < EXPECTED_NCPUS; i++) {
- if (!STREQ(params[i].field, VIR_DOMAIN_CPU_STATS_CPUTIME)) {
+ if (STRNEQ(params[i].field, VIR_DOMAIN_CPU_STATS_CPUTIME)) {
fprintf(stderr,
"Wrong parameter name value from
virCgroupGetPercpuStats at %zu (is: %s)\n",
i, params[i].field);
diff --git a/tests/virkeyfiletest.c b/tests/virkeyfiletest.c
index c31d2aa..3908fa8 100644
--- a/tests/virkeyfiletest.c
+++ b/tests/virkeyfiletest.c
@@ -70,17 +70,17 @@ static int testParse(const void *args ATTRIBUTE_UNUSED)
VIR_DEBUG("Missing Value 'Foo.three'");
goto cleanup;
}
- if (!STREQ(virKeyFileGetValueString(kf, "Foo", "one"),
+ if (STRNEQ(virKeyFileGetValueString(kf, "Foo", "one"),
"The first entry is here")) {
VIR_DEBUG("Wrong value for 'Foo.one'");
goto cleanup;
}
- if (!STREQ(virKeyFileGetValueString(kf, "Foo", "two"),
+ if (STRNEQ(virKeyFileGetValueString(kf, "Foo", "two"),
"The second entry")) {
VIR_DEBUG("Wrong value for 'Foo.one'");
goto cleanup;
}
- if (!STREQ(virKeyFileGetValueString(kf, "Foo", "three"),
+ if (STRNEQ(virKeyFileGetValueString(kf, "Foo", "three"),
"The third entry")) {
VIR_DEBUG("Wrong value for 'Foo.one'");
goto cleanup;
@@ -94,7 +94,7 @@ static int testParse(const void *args ATTRIBUTE_UNUSED)
VIR_DEBUG("Missing Value 'Bar.one'");
goto cleanup;
}
- if (!STREQ(virKeyFileGetValueString(kf, "Bar", "one"),
+ if (STRNEQ(virKeyFileGetValueString(kf, "Bar", "one"),
"The first entry in second group")) {
VIR_DEBUG("Wrong value for 'Bar.one'");
goto cleanup;
diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c
index 1ababad..ce9eeab 100644
--- a/tests/virnetsockettest.c
+++ b/tests/virnetsockettest.c
@@ -406,7 +406,7 @@ static int testSocketSSH(const void *opaque)
}
buf[rv] = '\0';
- if (!STREQ(buf, data->expectOut)) {
+ if (STRNEQ(buf, data->expectOut)) {
virtTestDifference(stderr, data->expectOut, buf);
goto cleanup;
}
diff --git a/tests/virtypedparamtest.c b/tests/virtypedparamtest.c
index b7bd72f..f4a5792 100644
--- a/tests/virtypedparamtest.c
+++ b/tests/virtypedparamtest.c
@@ -188,7 +188,7 @@ testTypedParamsGetStringList(const void *opaque
ATTRIBUTE_UNUSED)
goto cleanup;
continue;
}
- if (!STREQLEN(strings[i], "bar", 3))
+ if (STRNEQLEN(strings[i], "bar", 3))
goto cleanup;
if (strings[i][3] != l++)
goto cleanup;
diff --git a/tests/viruritest.c b/tests/viruritest.c
index 48b5865..e58e353 100644
--- a/tests/viruritest.c
+++ b/tests/viruritest.c
@@ -58,13 +58,13 @@ static int testURIParse(const void *args)
if (!(uri = virURIParse(data->uri)))
goto cleanup;
- if (!STREQ(uri->scheme, data->scheme)) {
+ if (STRNEQ(uri->scheme, data->scheme)) {
VIR_DEBUG("Expected scheme '%s', actual '%s'",
data->scheme, uri->scheme);
goto cleanup;
}
- if (!STREQ(uri->server, data->server)) {
+ if (STRNEQ(uri->server, data->server)) {
VIR_DEBUG("Expected server '%s', actual '%s'",
data->server, uri->server);
goto cleanup;
@@ -76,31 +76,31 @@ static int testURIParse(const void *args)
goto cleanup;
}
- if (!STREQ_NULLABLE(uri->path, data->path)) {
+ if (STRNEQ_NULLABLE(uri->path, data->path)) {
VIR_DEBUG("Expected path '%s', actual '%s'",
data->path, uri->path);
goto cleanup;
}
- if (!STREQ_NULLABLE(uri->query, data->query)) {
+ if (STRNEQ_NULLABLE(uri->query, data->query)) {
VIR_DEBUG("Expected query '%s', actual '%s'",
data->query, uri->query);
goto cleanup;
}
- if (!STREQ_NULLABLE(uri->fragment, data->fragment)) {
+ if (STRNEQ_NULLABLE(uri->fragment, data->fragment)) {
VIR_DEBUG("Expected fragment '%s', actual '%s'",
data->fragment, uri->fragment);
goto cleanup;
}
for (i = 0; data->params && data->params[i].name && i <
uri->paramsCount; i++) {
- if (!STREQ_NULLABLE(data->params[i].name, uri->params[i].name)) {
+ if (STRNEQ_NULLABLE(data->params[i].name, uri->params[i].name)) {
VIR_DEBUG("Expected param name %zu '%s', actual '%s'",
i, data->params[i].name, uri->params[i].name);
goto cleanup;
}
- if (!STREQ_NULLABLE(data->params[i].value, uri->params[i].value)) {
+ if (STRNEQ_NULLABLE(data->params[i].value, uri->params[i].value)) {
VIR_DEBUG("Expected param value %zu '%s', actual '%s'",
i, data->params[i].value, uri->params[i].value);
goto cleanup;
@@ -123,7 +123,7 @@ static int testURIParse(const void *args)
if (!(uristr = virURIFormat(uri)))
goto cleanup;
- if (!STREQ(uristr, data->uri_out)) {
+ if (STRNEQ(uristr, data->uri_out)) {
VIR_DEBUG("URI did not roundtrip, expect '%s', actual '%s'",
data->uri_out, uristr);
goto cleanup;
--
1.9.1
9 years, 2 months
[libvirt] [PATCH 2/2] Prefer STREQ and STRNEQ
by Ishmanpreet Khera
new syntax-check rule for !STREQ and !STRNEQ so that
we don't end up in the same situation again.
Signed-off-by: Ishmanpreet Kaur Khera <khera.ishman(a)gmail.com>
---
cfg.mk | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/cfg.mk b/cfg.mk
index e436434..7343dfc 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -1011,6 +1011,18 @@ sc_prohibit_pthread_create:
halt="avoid using 'pthread_create', use 'virThreadCreate' instead" \
$(_sc_search_regexp)
+sc_prohibit_not_streq:
+ @prohibit='!STREQ' \
+ exclude='exempt from syntax-check' \
+ halt='Use STRNEQ instead of !STREQ' \
+ $(_sc_search_regexp)
+
+sc_prohibit_not_strneq:
+ @prohibit='!STRNEQ' \
+ exclude='exempt from syntax-check' \
+ halt='Use STREQ instead of !STRNEQ' \
+ $(_sc_search_regexp)
+
# We don't use this feature of maint.mk.
prev_version_file = /dev/null
@@ -1213,3 +1225,9 @@
exclude_file_name_regexp--sc_prohibit_sysconf_pagesize = \
exclude_file_name_regexp--sc_prohibit_pthread_create = \
^(cfg\.mk|src/util/virthread\.c|tests/.*)$$
+
+exclude_file_name_regexp--sc_prohibit_not_streq = \
+ ^tests/.*\.[ch]$$
+
+exclude_file_name_regexp--sc_prohibit_not_strneq = \
+ ^tests/.*\.[ch]$$
--
1.9.1
9 years, 2 months
[libvirt] [PATCH v2 0/3] vz: implement some API calls
by Maxim Nestratov
v1-v2 change:
- removed vzConnectGetType
- addressed comments on vzConnectGetMaxVcpus
Maxim Nestratov (3):
vz: implement connectGetMaxVcpus API calls
vz: implement API calls of nodeGetxxx family
vz: implement some domain API calls
src/vz/vz_driver.c | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 109 insertions(+)
--
2.4.3
9 years, 2 months
[libvirt] [PATCH 1/3] vz: implement connectGetType and connectGetMaxVcpus API calls
by Maxim Nestratov
From: Maxim Nestratov <mnestratov(a)virtuozzo.com>
As a connection type we report 'vz'.
And because we have no limitation for maximal number of vcpus in containers
we report as maximum 1028 just for the sake of common sence.
Signed-off-by: Maxim Nestratov <mnestratov(a)virtuozzo.com>
---
src/vz/vz_driver.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 15dc70f..3cd6096 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -1337,12 +1337,31 @@ vzDomainMemoryStats(virDomainPtr domain,
return ret;
}
+static int vzConnectGetMaxVcpus(virConnectPtr conn ATTRIBUTE_UNUSED,
+ const char *type)
+{
+ /* As far as we have no limitation for containers
+ * we report maximum */
+ if (type == NULL || STRCASEEQ(type, "vz"))
+ return 1028;
+
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("unknown type '%s'"), type);
+ return -1;
+}
+
+static const char *vzConnectGetType(virConnectPtr conn ATTRIBUTE_UNUSED) {
+ return "vz";
+}
+
static virHypervisorDriver vzDriver = {
.name = "vz",
.connectOpen = vzConnectOpen, /* 0.10.0 */
.connectClose = vzConnectClose, /* 0.10.0 */
.connectGetVersion = vzConnectGetVersion, /* 0.10.0 */
.connectGetHostname = vzConnectGetHostname, /* 0.10.0 */
+ .connectGetType = vzConnectGetType, /* 1.2.21 */
+ .connectGetMaxVcpus = vzConnectGetMaxVcpus, /* 1.2.21 */
.nodeGetInfo = vzNodeGetInfo, /* 0.10.0 */
.connectGetCapabilities = vzConnectGetCapabilities, /* 0.10.0 */
.connectBaselineCPU = vzConnectBaselineCPU, /* 1.2.6 */
--
1.7.1
9 years, 2 months