[libvirt] [PATCH] Fix error reporting for getfd + host_net_add in QEMU
by Daniel P. Berrange
If either of the getfd or host_net_add monitor commands return
any text, this indicates an error condition. Don't ignore this!
* src/qemu/qemu_monitor_text.c: Report errors for getfd and
host_net_add
---
src/qemu/qemu_monitor_text.c | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 48c9a54..6ad07b1 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -1666,6 +1666,13 @@ int qemuMonitorTextSendFileHandle(qemuMonitorPtr mon,
goto cleanup;
}
+ if (STRNEQ(reply, "")) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unable to send TAP file handle: %s"),
+ reply);
+ goto cleanup;
+ }
+
ret = 0;
cleanup:
@@ -1725,11 +1732,16 @@ int qemuMonitorTextAddHostNetwork(qemuMonitorPtr mon,
if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
- _("failed to close fd in qemu with '%s'"), cmd);
+ _("failed to add host net with '%s'"), cmd);
goto cleanup;
}
- /* XXX error messages here ? */
+ if (STRNEQ(reply, "")) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unable to add host net: %s"),
+ reply);
+ goto cleanup;
+ }
ret = 0;
--
1.6.6.1
14 years, 7 months
[libvirt] [PATCH] Fix device_del in JSON mode for QEMU
by Daniel P. Berrange
The 'device_del' command expects a parameter called 'id' but we
were passing 'config'.
* src/qemu/qemu_monitor_json.c: Fix device_del command parameter
---
src/qemu/qemu_monitor_json.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 001b32b..c3ed47c 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2021,7 +2021,7 @@ int qemuMonitorJSONDelDevice(qemuMonitorPtr mon,
virJSONValuePtr reply = NULL;
cmd = qemuMonitorJSONMakeCommand("device_del",
- "s:config", devalias,
+ "s:id", devalias,
NULL);
if (!cmd)
return -1;
--
1.6.6.1
14 years, 7 months
[libvirt] [PATCH] Install nwfilter xml files from source directory.
by Philipp Hahn
During an out-of-tree build, the current working directory is the build
directory. Since the FILTERS are static and not modified or
auto-generated during the build process, they need to be explicitly
fetched from the source directory during install.
Prefix the files with $(srcdir), which gets expanded to the absolute or
relative path to the source directory, even when duing out-of-tree
builds.
Signed-off-by: Philipp Hahn <hahn(a)univention.de>
---
examples/xml/nwfilter/Makefile.am | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
14 years, 7 months
[libvirt] [TCK PATCH] default.cfg: fix typos
by Eric Blake
* conf/default.cfg: Improve spelling.
---
Pushing as obvious.
conf/default.cfg | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/conf/default.cfg b/conf/default.cfg
index 288540f..01f438c 100644
--- a/conf/default.cfg
+++ b/conf/default.cfg
@@ -13,12 +13,12 @@
# Defaults to /var/cache/libvirt-tck for root, or `pwd`/libvirt-tck for non-root
#scratch_dir = /var/cache/libvirt-tck
-# To avoid filling the filessytem, the test suite will
+# To avoid filling the filesystem, the test suite will
# automatically set a usage limit of
#
# freespace(scratch_dir) - 500 MB
#
-# The test suite will abort if it things it will exceed
+# The test suite will abort if it thinks it will exceed
# the limit.
#
# If you want to set a artificially lower usage limit...
--
1.6.6.1
14 years, 7 months
[libvirt] [TCK PATCH] maint: add copyright notices
by Eric Blake
The only non-trivial file (>15 lines, and not a simple listing
of other file names) that remains without a copyright notice
is the README.
* Build.PL: Add copyright.
* docs/intro.pod: Likewise.
* lib/Sys/Virt/TCK.pm: Likewise.
* lib/Sys/Virt/TCK/Capabilities.pm: Likewise.
* lib/Sys/Virt/TCK/DomainBuilder.pm: Likewise.
* lib/Sys/Virt/TCK/NetworkBuilder.pm: Likewise.
* lib/Sys/Virt/TCK/StoragePoolBuilder.pm: Likewise.
* lib/Sys/Virt/TCK/StorageVolBuilder.pm: Likewise.
* lib/Sys/Virt/TCK/TAP/XMLFormatter.pm: Likewise.
* lib/Sys/Virt/TCK/TAP/XMLFormatterSession.pm: Likewise.
* t/050-capabilities.t: Likewise.
* t/070-domain-builder.t: Likewise.
* t/080-network-builder.t: Likewise.
* t/090-storage-pool-builder.t: Likewise.
* t/100-storage-vol-builder.t: Likewise.
---
Build.PL | 12 ++++++++++++
autobuild.sh | 12 ++++++++++++
docs/intro.pod | 17 +++++++++++++++--
lib/Sys/Virt/TCK.pm | 12 ++++++++++++
lib/Sys/Virt/TCK/Capabilities.pm | 13 +++++++++++++
lib/Sys/Virt/TCK/DomainBuilder.pm | 13 +++++++++++++
lib/Sys/Virt/TCK/NetworkBuilder.pm | 13 +++++++++++++
lib/Sys/Virt/TCK/StoragePoolBuilder.pm | 13 +++++++++++++
lib/Sys/Virt/TCK/StorageVolBuilder.pm | 13 +++++++++++++
lib/Sys/Virt/TCK/TAP/XMLFormatter.pm | 13 +++++++++++++
lib/Sys/Virt/TCK/TAP/XMLFormatterSession.pm | 13 +++++++++++++
t/050-capabilities.t | 12 ++++++++++++
t/070-domain-builder.t | 12 ++++++++++++
t/080-network-builder.t | 12 ++++++++++++
t/090-storage-pool-builder.t | 12 ++++++++++++
t/100-storage-vol-builder.t | 12 ++++++++++++
16 files changed, 202 insertions(+), 2 deletions(-)
diff --git a/Build.PL b/Build.PL
index c85a072..ce30f36 100644
--- a/Build.PL
+++ b/Build.PL
@@ -1,4 +1,16 @@
#!/usr/bin/perl
+#
+# Copyright (C) 2009 Red Hat, Inc.
+# Copyright (C) 2009 Daniel P. Berrange
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
use Module::Build;
diff --git a/autobuild.sh b/autobuild.sh
index 8d1ad53..f195602 100755
--- a/autobuild.sh
+++ b/autobuild.sh
@@ -2,6 +2,18 @@
#
# This script is used to Test::AutoBuild (http://www.autobuild.org)
# to perform automated builds of the Sys-Virt module
+#
+# Copyright (C) 2009 Red Hat, Inc.
+# Copyright (C) 2009 Daniel P. Berrange
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
NAME=Sys-Virt-TCK
diff --git a/docs/intro.pod b/docs/intro.pod
index 592e145..5943f3b 100644
--- a/docs/intro.pod
+++ b/docs/intro.pod
@@ -1,3 +1,16 @@
+#
+# Copyright (C) 2009 Red Hat, Inc.
+# Copyright (C) 2009 Daniel P. Berrange
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
+
=pod
=head1 libvirt TCK: Technology Compatability Kit
@@ -166,7 +179,7 @@ the libvirt TCK, there is a small program
Given no arguments, this will connect using the default hypervisor
URI and a previously obtained kernel+initrd and run all the tests
currently available for the libvirt TCK, and report on failures.
-It comes witha number of options to alter the output format or
+It comes with a number of options to alter the output format or
choose different configurations. 'man 1 libvirt-tck' will produce
details
@@ -309,7 +322,7 @@ up some pre-requisite pieces. Specifically it would
=item *
-Build an bootable ISO image using the kernel+initrd
+Build a bootable ISO image using the kernel+initrd
=item *
diff --git a/lib/Sys/Virt/TCK.pm b/lib/Sys/Virt/TCK.pm
index d32b03d..ea2b1d2 100644
--- a/lib/Sys/Virt/TCK.pm
+++ b/lib/Sys/Virt/TCK.pm
@@ -1,3 +1,15 @@
+#
+# Copyright (C) 2009-2010 Red Hat, Inc.
+# Copyright (C) 2009 Daniel P. Berrange
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
package Sys::Virt::TCK;
diff --git a/lib/Sys/Virt/TCK/Capabilities.pm b/lib/Sys/Virt/TCK/Capabilities.pm
index b15e195..8b79db4 100644
--- a/lib/Sys/Virt/TCK/Capabilities.pm
+++ b/lib/Sys/Virt/TCK/Capabilities.pm
@@ -1,3 +1,16 @@
+#
+# Copyright (C) 2009 Red Hat, Inc.
+# Copyright (C) 2009 Daniel P. Berrange
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
+
package Sys::Virt::TCK::Capabilities;
use strict;
diff --git a/lib/Sys/Virt/TCK/DomainBuilder.pm b/lib/Sys/Virt/TCK/DomainBuilder.pm
index 199884b..3bf5976 100644
--- a/lib/Sys/Virt/TCK/DomainBuilder.pm
+++ b/lib/Sys/Virt/TCK/DomainBuilder.pm
@@ -1,3 +1,16 @@
+#
+# Copyright (C) 2009-2010 Red Hat, Inc.
+# Copyright (C) 2009 Daniel P. Berrange
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
+
package Sys::Virt::TCK::DomainBuilder;
use strict;
diff --git a/lib/Sys/Virt/TCK/NetworkBuilder.pm b/lib/Sys/Virt/TCK/NetworkBuilder.pm
index e62b3e2..00b75d2 100644
--- a/lib/Sys/Virt/TCK/NetworkBuilder.pm
+++ b/lib/Sys/Virt/TCK/NetworkBuilder.pm
@@ -1,3 +1,16 @@
+#
+# Copyright (C) 2009, 2010 Red Hat, Inc.
+# Copyright (C) 2009 Daniel P. Berrange
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
+
package Sys::Virt::TCK::NetworkBuilder;
use strict;
diff --git a/lib/Sys/Virt/TCK/StoragePoolBuilder.pm b/lib/Sys/Virt/TCK/StoragePoolBuilder.pm
index c9ef2dd..c33f43b 100644
--- a/lib/Sys/Virt/TCK/StoragePoolBuilder.pm
+++ b/lib/Sys/Virt/TCK/StoragePoolBuilder.pm
@@ -1,3 +1,16 @@
+#
+# Copyright (C) 2009, 2010 Red Hat, Inc.
+# Copyright (C) 2009 Daniel P. Berrange
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
+
package Sys::Virt::TCK::StoragePoolBuilder;
use strict;
diff --git a/lib/Sys/Virt/TCK/StorageVolBuilder.pm b/lib/Sys/Virt/TCK/StorageVolBuilder.pm
index 940d70e..00680ed 100644
--- a/lib/Sys/Virt/TCK/StorageVolBuilder.pm
+++ b/lib/Sys/Virt/TCK/StorageVolBuilder.pm
@@ -1,3 +1,16 @@
+#
+# Copyright (C) 2009, 2010 Red Hat, Inc.
+# Copyright (C) 2009 Daniel P. Berrange
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
+
package Sys::Virt::TCK::StorageVolBuilder;
use strict;
diff --git a/lib/Sys/Virt/TCK/TAP/XMLFormatter.pm b/lib/Sys/Virt/TCK/TAP/XMLFormatter.pm
index e601744..b4514fd 100644
--- a/lib/Sys/Virt/TCK/TAP/XMLFormatter.pm
+++ b/lib/Sys/Virt/TCK/TAP/XMLFormatter.pm
@@ -1,3 +1,16 @@
+#
+# Copyright (C) 2009 Red Hat, Inc.
+# Copyright (C) 2009 Daniel P. Berrange
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
+
package Sys::Virt::TCK::TAP::XMLFormatter;
use strict;
diff --git a/lib/Sys/Virt/TCK/TAP/XMLFormatterSession.pm b/lib/Sys/Virt/TCK/TAP/XMLFormatterSession.pm
index b403140..ca2a298 100644
--- a/lib/Sys/Virt/TCK/TAP/XMLFormatterSession.pm
+++ b/lib/Sys/Virt/TCK/TAP/XMLFormatterSession.pm
@@ -1,3 +1,16 @@
+#
+# Copyright (C) 2009 Red Hat, Inc.
+# Copyright (C) 2009 Daniel P. Berrange
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
+
package Sys::Virt::TCK::TAP::XMLFormatterSession;
use strict;
diff --git a/t/050-capabilities.t b/t/050-capabilities.t
index 9f65ef7..691b9d5 100644
--- a/t/050-capabilities.t
+++ b/t/050-capabilities.t
@@ -1,4 +1,16 @@
# -*- perl -*-
+#
+# Copyright (C) 2009 Red Hat, Inc.
+# Copyright (C) 2009 Daniel P. Berrange
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
use Test::More tests => 77;
diff --git a/t/070-domain-builder.t b/t/070-domain-builder.t
index ff0eb78..c460448 100644
--- a/t/070-domain-builder.t
+++ b/t/070-domain-builder.t
@@ -1,4 +1,16 @@
# -*- perl -*-
+#
+# Copyright (C) 2009, 2010 Red Hat, Inc.
+# Copyright (C) 2009 Daniel P. Berrange
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
use Test::More tests => 2;
diff --git a/t/080-network-builder.t b/t/080-network-builder.t
index 4804e32..ec2b70c 100644
--- a/t/080-network-builder.t
+++ b/t/080-network-builder.t
@@ -1,4 +1,16 @@
# -*- perl -*-
+#
+# Copyright (C) 2009, 2010 Red Hat, Inc.
+# Copyright (C) 2009 Daniel P. Berrange
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
use Test::More tests => 2;
diff --git a/t/090-storage-pool-builder.t b/t/090-storage-pool-builder.t
index 67e800d..b31204a 100644
--- a/t/090-storage-pool-builder.t
+++ b/t/090-storage-pool-builder.t
@@ -1,4 +1,16 @@
# -*- perl -*-
+#
+# Copyright (C) 2009, 2010 Red Hat, Inc.
+# Copyright (C) 2009 Daniel P. Berrange
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
use Test::More tests => 8;
use strict;
diff --git a/t/100-storage-vol-builder.t b/t/100-storage-vol-builder.t
index 017301e..d168ecd 100644
--- a/t/100-storage-vol-builder.t
+++ b/t/100-storage-vol-builder.t
@@ -1,4 +1,16 @@
# -*- perl -*-
+#
+# Copyright (C) 2009, 2010 Red Hat, Inc.
+# Copyright (C) 2009 Daniel P. Berrange
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
use Test::More tests => 2;
--
1.6.6.1
14 years, 7 months
[libvirt] [PATCH] esx: Replace scanf with STRSKIP and strtok_r
by Matthias Bolte
This also fixes a portability problem with the %a format modifier.
%a is not portable and made esxDomainDumpXML fail at runtime in
MinGW builds.
Pull in strtok_r from gnulib, because MinGW lacks it.
---
bootstrap.conf | 1 +
src/esx/esx_driver.c | 19 +++--------------
src/esx/esx_util.c | 53 +++++++++++++++++++++++++------------------------
src/esx/esx_vi.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
src/esx/esx_vi.h | 12 +++++++++++
src/esx/esx_vmx.c | 16 +++++++++++---
6 files changed, 106 insertions(+), 45 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index d807e40..785489b 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -54,6 +54,7 @@ strndup
strerror
strptime
strsep
+strtok_r
sys_stat
time_r
timegm
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index a2fc85c..f22634e 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -60,8 +60,8 @@ esxSupportsLongMode(esxPrivate *priv)
esxVI_DynamicProperty *dynamicProperty = NULL;
esxVI_HostCpuIdInfo *hostCpuIdInfoList = NULL;
esxVI_HostCpuIdInfo *hostCpuIdInfo = NULL;
+ esxVI_ParsedHostCpuIdInfo parsedHostCpuIdInfo;
char edxLongModeBit = '?';
- char edxFirstBit = '?';
if (priv->supportsLongMode != esxVI_Boolean_Undefined) {
return priv->supportsLongMode;
@@ -96,23 +96,12 @@ esxSupportsLongMode(esxPrivate *priv)
for (hostCpuIdInfo = hostCpuIdInfoList; hostCpuIdInfo != NULL;
hostCpuIdInfo = hostCpuIdInfo->_next) {
if (hostCpuIdInfo->level->value == -2147483647) { /* 0x80000001 */
-#define _SKIP4 "%*c%*c%*c%*c"
-#define _SKIP12 _SKIP4":"_SKIP4":"_SKIP4
-
- /* Expected format: "--X-:----:----:----:----:----:----:----" */
- if (sscanf(hostCpuIdInfo->edx,
- "%*c%*c%c%*c:"_SKIP12":"_SKIP12":%*c%*c%*c%c",
- &edxLongModeBit, &edxFirstBit) != 2) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("HostSystem property 'hardware.cpuFeature[].edx' "
- "with value '%s' doesn't have expected format "
- "'----:----:----:----:----:----:----:----'"),
- hostCpuIdInfo->edx);
+ if (esxVI_ParseHostCpuIdInfo(&parsedHostCpuIdInfo,
+ hostCpuIdInfo) < 0) {
goto failure;
}
-#undef _SKIP4
-#undef _SKIP12
+ edxLongModeBit = parsedHostCpuIdInfo.edx[29];
if (edxLongModeBit == '1') {
priv->supportsLongMode = esxVI_Boolean_True;
diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index 963f52e..91d19e9 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -203,6 +203,10 @@ esxUtil_ParseDatastoreRelatedPath(const char *datastoreRelatedPath,
char **directoryName, char **fileName)
{
int result = 0;
+ char *copyOfDatastoreRelatedPath = NULL;
+ char *tmp = NULL;
+ char *saveptr = NULL;
+ char *preliminaryDatastoreName = NULL;
char *directoryAndFileName = NULL;
char *separator = NULL;
@@ -213,37 +217,34 @@ esxUtil_ParseDatastoreRelatedPath(const char *datastoreRelatedPath,
return -1;
}
- /*
- * Parse string as '[<datastore>] <path>'. '%as' is similar to '%s', but
- * sscanf() will allocate the memory for the string, so the caller doesn't
- * need to preallocate a buffer that's large enough.
- *
- * The s in '%as' can be replaced with a character set, e.g. [a-z].
- *
- * '%a[^]%]' matches <datastore>. '[^]%]' excludes ']' from the accepted
- * characters, otherwise sscanf() wont match what it should.
- *
- * '%a[^\n]' matches <path>. '[^\n]' excludes '\n' from the accepted
- * characters, otherwise sscanf() would only match up to the first space,
- * but spaces are valid in <path>.
- */
- if (sscanf(datastoreRelatedPath, "[%a[^]%]] %a[^\n]", datastoreName,
- &directoryAndFileName) != 2) {
+ if (esxVI_String_DeepCopyValue(©OfDatastoreRelatedPath,
+ datastoreRelatedPath) < 0) {
+ goto failure;
+ }
+
+ /* Expected format: '[<datastore>] <path>' */
+ if ((tmp = STRSKIP(copyOfDatastoreRelatedPath, "[")) == NULL ||
+ (preliminaryDatastoreName = strtok_r(tmp, "]", &saveptr)) == NULL ||
+ (directoryAndFileName = strtok_r(NULL, "", &saveptr)) == NULL) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Datastore related path '%s' doesn't have expected format "
"'[<datastore>] <path>'"), datastoreRelatedPath);
goto failure;
}
+ if (esxVI_String_DeepCopyValue(datastoreName,
+ preliminaryDatastoreName) < 0) {
+ goto failure;
+ }
+
+ directoryAndFileName += strspn(directoryAndFileName, " ");
+
/* Split <path> into <directory>/<file>, where <directory> is optional */
separator = strrchr(directoryAndFileName, '/');
if (separator != NULL) {
*separator++ = '\0';
- *directoryName = directoryAndFileName;
- directoryAndFileName = NULL;
-
if (*separator == '\0') {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Datastore related path '%s' doesn't reference a file"),
@@ -251,19 +252,19 @@ esxUtil_ParseDatastoreRelatedPath(const char *datastoreRelatedPath,
goto failure;
}
- *fileName = strdup(separator);
-
- if (*fileName == NULL) {
- virReportOOMError();
+ if (esxVI_String_DeepCopyValue(directoryName,
+ directoryAndFileName) < 0 ||
+ esxVI_String_DeepCopyValue(fileName, separator) < 0) {
goto failure;
}
} else {
- *fileName = directoryAndFileName;
- directoryAndFileName = NULL;
+ if (esxVI_String_DeepCopyValue(fileName, directoryAndFileName) < 0) {
+ goto failure;
+ }
}
cleanup:
- VIR_FREE(directoryAndFileName);
+ VIR_FREE(copyOfDatastoreRelatedPath);
return result;
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 4318ff1..db8c927 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -2886,3 +2886,53 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
goto cleanup;
}
+
+
+
+int
+esxVI_ParseHostCpuIdInfo(esxVI_ParsedHostCpuIdInfo *parsedhostCpuIdInfo,
+ esxVI_HostCpuIdInfo *hostCpuIdInfo)
+{
+ int expectedLength = 39; /* = strlen("----:----:----:----:----:----:----:----"); */
+ char *input[4] = { hostCpuIdInfo->eax, hostCpuIdInfo->ebx,
+ hostCpuIdInfo->ecx, hostCpuIdInfo->edx };
+ char *output[4] = { parsedhostCpuIdInfo->eax, parsedhostCpuIdInfo->ebx,
+ parsedhostCpuIdInfo->ecx, parsedhostCpuIdInfo->edx };
+ const char *name[4] = { "eax", "ebx", "ecx", "edx" };
+ int r, i, o;
+
+ memset(parsedhostCpuIdInfo, 0, sizeof (esxVI_ParsedHostCpuIdInfo));
+
+ parsedhostCpuIdInfo->level = hostCpuIdInfo->level->value;
+
+ for (r = 0; r < 4; ++r) {
+ if (strlen(input[r]) != expectedLength) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("HostCpuIdInfo register '%s' has an unexpected length"),
+ name[r]);
+ goto failure;
+ }
+
+ /* Strip the ':' and invert the "bit" order from 31..0 to 0..31 */
+ for (i = 0, o = 31; i < expectedLength; i += 5, o -= 4) {
+ output[r][o] = input[r][i];
+ output[r][o - 1] = input[r][i + 1];
+ output[r][o - 2] = input[r][i + 2];
+ output[r][o - 3] = input[r][i + 3];
+
+ if (i + 4 < expectedLength && input[r][i + 4] != ':') {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("HostCpuIdInfo register '%s' has an unexpected format"),
+ name[r]);
+ goto failure;
+ }
+ }
+ }
+
+ return 0;
+
+ failure:
+ memset(parsedhostCpuIdInfo, 0, sizeof (esxVI_ParsedHostCpuIdInfo));
+
+ return -1;
+}
diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h
index a8d4cc3..45b83f5 100644
--- a/src/esx/esx_vi.h
+++ b/src/esx/esx_vi.h
@@ -43,6 +43,7 @@
typedef enum _esxVI_APIVersion esxVI_APIVersion;
typedef enum _esxVI_ProductVersion esxVI_ProductVersion;
typedef enum _esxVI_Occurrence esxVI_Occurrence;
+typedef struct _esxVI_ParsedHostCpuIdInfo esxVI_ParsedHostCpuIdInfo;
typedef struct _esxVI_Context esxVI_Context;
typedef struct _esxVI_Response esxVI_Response;
typedef struct _esxVI_Enumeration esxVI_Enumeration;
@@ -76,6 +77,14 @@ enum _esxVI_Occurrence {
esxVI_Occurrence_None
};
+struct _esxVI_ParsedHostCpuIdInfo {
+ int level;
+ char eax[32];
+ char ebx[32];
+ char ecx[32];
+ char edx[32];
+};
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
@@ -313,4 +322,7 @@ int esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
esxVI_Boolean autoAnswer,
esxVI_TaskInfoState *finalState);
+int esxVI_ParseHostCpuIdInfo(esxVI_ParsedHostCpuIdInfo *parsedhostCpuIdInfo,
+ esxVI_HostCpuIdInfo *hostCpuIdInfo);
+
#endif /* __ESX_VI_H__ */
diff --git a/src/esx/esx_vmx.c b/src/esx/esx_vmx.c
index c965e00..c2e9be6 100644
--- a/src/esx/esx_vmx.c
+++ b/src/esx/esx_vmx.c
@@ -589,6 +589,9 @@ char *
esxVMX_AbsolutePathToDatastoreRelatedPath(esxVI_Context *ctx,
const char *absolutePath)
{
+ char *copyOfAbsolutePath = NULL;
+ char *tmp = NULL;
+ char *saveptr = NULL;
char *datastoreRelatedPath = NULL;
char *preliminaryDatastoreName = NULL;
char *directoryAndFileName = NULL;
@@ -596,8 +599,14 @@ esxVMX_AbsolutePathToDatastoreRelatedPath(esxVI_Context *ctx,
esxVI_ObjectContent *datastore = NULL;
const char *datastoreName = NULL;
- if (sscanf(absolutePath, "/vmfs/volumes/%a[^/]/%a[^\n]",
- &preliminaryDatastoreName, &directoryAndFileName) != 2) {
+ if (esxVI_String_DeepCopyValue(©OfAbsolutePath, absolutePath) < 0) {
+ goto failure;
+ }
+
+ /* Expected format: '/vmfs/volumes/<datastore>/<path>' */
+ if ((tmp = STRSKIP(copyOfAbsolutePath, "/vmfs/volumes/")) == NULL ||
+ (preliminaryDatastoreName = strtok_r(tmp, "/", &saveptr)) == NULL ||
+ (directoryAndFileName = strtok_r(NULL, "", &saveptr)) == NULL) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Absolute path '%s' doesn't have expected format "
"'/vmfs/volumes/<datastore>/<path>'"), absolutePath);
@@ -652,8 +661,7 @@ esxVMX_AbsolutePathToDatastoreRelatedPath(esxVI_Context *ctx,
/* FIXME: Check if referenced path/file really exists */
cleanup:
- VIR_FREE(preliminaryDatastoreName);
- VIR_FREE(directoryAndFileName);
+ VIR_FREE(copyOfAbsolutePath);
esxVI_ObjectContent_Free(&datastore);
return datastoreRelatedPath;
--
1.6.3.3
14 years, 7 months
[libvirt] [PATCH] Update to latest gnulib to get strtok_r relaxed to LGPLv2+
by Matthias Bolte
strtok_r will be used in the ESX driver to replace scanf-based code.
MinGW lacks strtok_r, so we need gnulib to provide it, but until now
strtok_r was licensed LGPL3.
---
.gnulib | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/.gnulib b/.gnulib
index 097c9ce..7c1b995 160000
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit 097c9ce08a79899ff942b9b6ee811e613605499f
+Subproject commit 7c1b995a7041ea366acafeb8632e1080f349f03f
--
1.6.3.3
14 years, 7 months
[libvirt] [PATCH] maint: another preprocessor fix
by Eric Blake
Regression introduced in commit 62170b995.
* src/util/memory.h: Placate cppi, and fit 80 columns.
---
Pushing this as obvious, for 'make syntax-check'.
src/util/memory.h | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/util/memory.h b/src/util/memory.h
index ad458a6..60e2be6 100644
--- a/src/util/memory.h
+++ b/src/util/memory.h
@@ -1,6 +1,7 @@
/*
* memory.c: safer memory allocation
*
+ * Copyright (C) 2010 Red Hat, Inc.
* Copyright (C) 2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -102,7 +103,7 @@ void virFree(void *ptrptr);
* arithmetic overflow in the allocation size. The check is
* essentially the same as that in gnulib's xalloc_oversized.
*/
-#define VIR_ALLOC_VAR_OVERSIZED(M, N, S) ((((size_t)-1) - (M)) / (S) < (N))
+# define VIR_ALLOC_VAR_OVERSIZED(M, N, S) ((((size_t)-1) - (M)) / (S) < (N))
/**
* VIR_ALLOC_VAR:
@@ -121,7 +122,8 @@ void virFree(void *ptrptr);
* Returns -1 on failure, 0 on success
*/
-#define VIR_ALLOC_VAR(ptr, type, count) virAllocVar(&(ptr), sizeof(*(ptr)), sizeof(type), (count))
+# define VIR_ALLOC_VAR(ptr, type, count) \
+ virAllocVar(&(ptr), sizeof(*(ptr)), sizeof(type), (count))
/**
* VIR_FREE:
--
1.6.6.1
14 years, 7 months