Devel
Threads by month
- ----- 2026 -----
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- 50 participants
- 40235 discussions
Noticed during the recent error cleanups.
* src/network/bridge_driver.c (networkStartRadvd): Fix spacing.
* src/openvz/openvz_conf.c (openvzReadMemConf): Likewise.
* src/qemu/qemu_command.c (qemuNetworkIfaceConnect): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainDetachNetDevice): Likewise.
* src/qemu/qemu_process.c (qemuProcessStop): Likewise.
* src/security/virt-aa-helper.c (vah_add_file): Likewise.
---
Pushing under the trivial rule.
src/network/bridge_driver.c | 2 +-
src/openvz/openvz_conf.c | 2 +-
src/qemu/qemu_command.c | 2 +-
src/qemu/qemu_hotplug.c | 2 +-
src/qemu/qemu_process.c | 2 +-
src/security/virt-aa-helper.c | 8 ++++----
6 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 9b1964b..5bf1412 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -850,7 +850,7 @@ networkStartRadvd(virNetworkObjPtr network)
prefix = virNetworkIpDefPrefix(ipdef);
if (prefix < 0) {
networkReportError(VIR_ERR_INTERNAL_ERROR,
- _("bridge '%s' has an invalid prefix"),
+ _("bridge '%s' has an invalid prefix"),
network->def->bridge);
goto cleanup;
}
diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index bc54012..57479d4 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -511,7 +511,7 @@ openvzReadMemConf(virDomainDefPtr def, int veid)
ret = openvzParseBarrierLimit(temp, &barrier, NULL);
if (ret < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
- _("Could not parse barrier of '%s' "
+ _("Could not parse barrier of '%s' "
"from config for container %d"), param, veid);
goto error;
}
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 09215af..4013740 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -265,7 +265,7 @@ qemuNetworkIfaceConnect(virDomainDefPtr def,
if (driver->macFilter) {
if ((err = networkAllowMacOnPort(driver, net->ifname, &net->mac))) {
virReportSystemError(err,
- _("failed to add ebtables rule to allow MAC address on '%s'"),
+ _("failed to add ebtables rule to allow MAC address on '%s'"),
net->ifname);
}
}
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 09c8c97..5a9a6f7 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2293,7 +2293,7 @@ qemuDomainDetachNetDevice(struct qemud_driver *driver,
detach->ifname,
&detach->mac))) {
virReportSystemError(errno,
- _("failed to remove ebtables rule on '%s'"),
+ _("failed to remove ebtables rule on '%s'"),
detach->ifname);
}
}
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index d8169e8..b260a20 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4029,7 +4029,7 @@ void qemuProcessStop(struct qemud_driver *driver,
if ((errno = networkDisallowMacOnPort(driver, net->ifname,
&net->mac))) {
virReportSystemError(errno,
- _("failed to remove ebtables rule to allow MAC address on '%s'"),
+ _("failed to remove ebtables rule to allow MAC address on '%s'"),
net->ifname);
}
}
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 7b41d38..056362c 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -2,7 +2,7 @@
/*
* virt-aa-helper: wrapper program used by AppArmor security driver.
*
- * Copyright (C) 2010-2011 Red Hat, Inc.
+ * Copyright (C) 2010-2012 Red Hat, Inc.
* Copyright (C) 2009-2011 Canonical Ltd.
*
* See COPYING.LIB for the License of this software
@@ -762,14 +762,14 @@ vah_add_file(virBufferPtr buf, const char *path, const char *perms)
*/
if (STRNEQLEN(path, "/", 1)) {
vah_warning(path);
- vah_warning(_(" skipped non-absolute path"));
+ vah_warning(_("skipped non-absolute path"));
return 0;
}
if (virFileExists(path)) {
if ((tmp = realpath(path, NULL)) == NULL) {
vah_error(NULL, 0, path);
- vah_error(NULL, 0, _(" could not find realpath for disk"));
+ vah_error(NULL, 0, _("could not find realpath for disk"));
return rc;
}
} else
@@ -783,7 +783,7 @@ vah_add_file(virBufferPtr buf, const char *path, const char *perms)
if (rc != 0) {
if (rc > 0) {
vah_error(NULL, 0, path);
- vah_error(NULL, 0, _(" skipped restricted file"));
+ vah_error(NULL, 0, _("skipped restricted file"));
}
goto clean;
}
--
1.7.10.4
1
0
It was broken since forever as it expected a libxml2
XML_ELEMENT_NODE containing a XML_TEXT_NODE instead of
just a XML_TEXT_NODE.
This problem was not discovered for so long because
esxVI_String_Deserialize was not used until now.
Reported by Ata Bohra
---
src/esx/esx_vi_types.c | 23 +++++++++++++++++++----
1 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index bcc310f..844fb65 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -1227,11 +1227,26 @@ esxVI_String_SerializeValue(const char *value, const char *element,
return 0;
}
-/* esxVI_String_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(String,
+int
+esxVI_String_Deserialize(xmlNodePtr node, esxVI_String **string)
{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, value)
-})
+ if (string == NULL || *string != NULL) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ return -1;
+ }
+
+ if (esxVI_String_Alloc(string) < 0 ||
+ esxVI_String_DeserializeValue(node, &(*string)->value) < 0) {
+ goto failure;
+ }
+
+ return 0;
+
+ failure:
+ esxVI_String_Free(string);
+
+ return -1;
+}
/* esxVI_String_DeserializeList */
ESX_VI__TEMPLATE__LIST__DESERIALIZE(String)
--
1.7.4.1
2
2
Commit 80533ca forgot to think about offline cpus. When a node
cpu is offline, then its topology/ subdirectory is not present,
leading to spurious error messages leaked to the user such as:
libvir: error : cannot open /home/dummy/libvirt/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu7/topology/physical_package_id: No such file or directory
Fix that, as well as test it; the test data is gathered from a
machine with one NUMA node, hyperthreading, and with 2 of the
8 cpus offline.
* src/nodeinfo.c (virNodeParseNode): Don't parse topology of
offline cpus.
* tests/nodeinfotest.c (mymain): Run new test.
* tests/nodeinfodata/linux-nodeinfo-sysfs-test-6*: New data.
---
Offline cpus are an annoying corner case :)
src/nodeinfo.c | 6 +
.../linux-nodeinfo-sysfs-test-6-cpu-x86-output.txt | 1 +
.../linux-nodeinfo-sysfs-test-6-x86.cpuinfo | 150 ++++++++++++++++++++
.../cpu/cpu0/topology/core_id | 1 +
.../cpu/cpu0/topology/physical_package_id | 1 +
.../cpu/cpu0/topology/thread_siblings | 1 +
.../linux-nodeinfo-sysfs-test-6/cpu/cpu1/online | 1 +
.../cpu/cpu1/topology/core_id | 1 +
.../cpu/cpu1/topology/physical_package_id | 1 +
.../cpu/cpu1/topology/thread_siblings | 1 +
.../linux-nodeinfo-sysfs-test-6/cpu/cpu2/online | 1 +
.../cpu/cpu2/topology/core_id | 1 +
.../cpu/cpu2/topology/physical_package_id | 1 +
.../cpu/cpu2/topology/thread_siblings | 1 +
.../linux-nodeinfo-sysfs-test-6/cpu/cpu3/online | 1 +
.../cpu/cpu3/topology/core_id | 1 +
.../cpu/cpu3/topology/physical_package_id | 1 +
.../cpu/cpu3/topology/thread_siblings | 1 +
.../linux-nodeinfo-sysfs-test-6/cpu/cpu4/online | 1 +
.../cpu/cpu4/topology/core_id | 1 +
.../cpu/cpu4/topology/physical_package_id | 1 +
.../cpu/cpu4/topology/thread_siblings | 1 +
.../linux-nodeinfo-sysfs-test-6/cpu/cpu5/online | 1 +
.../linux-nodeinfo-sysfs-test-6/cpu/cpu6/online | 1 +
.../cpu/cpu6/topology/core_id | 1 +
.../cpu/cpu6/topology/physical_package_id | 1 +
.../cpu/cpu6/topology/thread_siblings | 1 +
.../linux-nodeinfo-sysfs-test-6/cpu/cpu7/online | 1 +
.../linux-nodeinfo-sysfs-test-6/node/node0/cpu0 | 1 +
.../linux-nodeinfo-sysfs-test-6/node/node0/cpu1 | 1 +
.../linux-nodeinfo-sysfs-test-6/node/node0/cpu2 | 1 +
.../linux-nodeinfo-sysfs-test-6/node/node0/cpu3 | 1 +
.../linux-nodeinfo-sysfs-test-6/node/node0/cpu4 | 1 +
.../linux-nodeinfo-sysfs-test-6/node/node0/cpu5 | 1 +
.../linux-nodeinfo-sysfs-test-6/node/node0/cpu6 | 1 +
.../linux-nodeinfo-sysfs-test-6/node/node0/cpu7 | 1 +
.../linux-nodeinfo-sysfs-test-6/node/node0/meminfo | 29 ++++
.../linux-nodeinfo-sysfs-test-6/node/online | Bin 0 -> 3 bytes
.../linux-nodeinfo-sysfs-test-6/node/possible | Bin 0 -> 3 bytes
tests/nodeinfotest.c | 1 +
40 files changed, 220 insertions(+)
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6-cpu-x86-output.txt
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6-x86.cpuinfo
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu0/topology/core_id
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu0/topology/physical_package_id
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu0/topology/thread_siblings
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu1/online
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu1/topology/core_id
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu1/topology/physical_package_id
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu1/topology/thread_siblings
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu2/online
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu2/topology/core_id
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu2/topology/physical_package_id
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu2/topology/thread_siblings
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu3/online
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu3/topology/core_id
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu3/topology/physical_package_id
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu3/topology/thread_siblings
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu4/online
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu4/topology/core_id
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu4/topology/physical_package_id
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu4/topology/thread_siblings
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu5/online
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu6/online
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu6/topology/core_id
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu6/topology/physical_package_id
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu6/topology/thread_siblings
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu7/online
create mode 120000 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu0
create mode 120000 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu1
create mode 120000 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu2
create mode 120000 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu3
create mode 120000 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu4
create mode 120000 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu5
create mode 120000 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu6
create mode 120000 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu7
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/meminfo
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/online
create mode 100644 tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/possible
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index a892e7a..052b006 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -225,6 +225,12 @@ virNodeParseNode(const char *node, int *sockets, int *cores, int *threads)
if (sscanf(cpudirent->d_name, "cpu%u", &cpu) != 1)
continue;
+ if ((online = virNodeGetCpuValue(node, cpu, "online", true)) < 0)
+ goto cleanup;
+
+ if (!online)
+ continue;
+
/* Parse socket */
sock = virNodeParseSocket(node, cpu);
CPU_SET(sock, &sock_map);
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6-cpu-x86-output.txt b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6-cpu-x86-output.txt
new file mode 100644
index 0000000..7ffcb8e
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6-cpu-x86-output.txt
@@ -0,0 +1 @@
+CPUs: 6/8, MHz: 1596, Nodes: 1, Sockets: 1, Cores: 4, Threads: 2
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6-x86.cpuinfo b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6-x86.cpuinfo
new file mode 100644
index 0000000..61838dd
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6-x86.cpuinfo
@@ -0,0 +1,150 @@
+processor : 0
+vendor_id : GenuineIntel
+cpu family : 6
+model : 44
+model name : Intel(R) Xeon(R) CPU E5640 @ 2.67GHz
+stepping : 2
+cpu MHz : 1596.000
+cache size : 12288 KB
+physical id : 0
+siblings : 6
+core id : 0
+cpu cores : 4
+apicid : 0
+initial apicid : 0
+fpu : yes
+fpu_exception : yes
+cpuid level : 11
+wp : yes
+flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid
+bogomips : 5333.90
+clflush size : 64
+cache_alignment : 64
+address sizes : 40 bits physical, 48 bits virtual
+power management:
+
+processor : 1
+vendor_id : GenuineIntel
+cpu family : 6
+model : 44
+model name : Intel(R) Xeon(R) CPU E5640 @ 2.67GHz
+stepping : 2
+cpu MHz : 1596.000
+cache size : 12288 KB
+physical id : 0
+siblings : 6
+core id : 1
+cpu cores : 4
+apicid : 2
+initial apicid : 2
+fpu : yes
+fpu_exception : yes
+cpuid level : 11
+wp : yes
+flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid
+bogomips : 5333.90
+clflush size : 64
+cache_alignment : 64
+address sizes : 40 bits physical, 48 bits virtual
+power management:
+
+processor : 2
+vendor_id : GenuineIntel
+cpu family : 6
+model : 44
+model name : Intel(R) Xeon(R) CPU E5640 @ 2.67GHz
+stepping : 2
+cpu MHz : 1596.000
+cache size : 12288 KB
+physical id : 0
+siblings : 6
+core id : 9
+cpu cores : 4
+apicid : 18
+initial apicid : 18
+fpu : yes
+fpu_exception : yes
+cpuid level : 11
+wp : yes
+flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid
+bogomips : 5333.90
+clflush size : 64
+cache_alignment : 64
+address sizes : 40 bits physical, 48 bits virtual
+power management:
+
+processor : 3
+vendor_id : GenuineIntel
+cpu family : 6
+model : 44
+model name : Intel(R) Xeon(R) CPU E5640 @ 2.67GHz
+stepping : 2
+cpu MHz : 1596.000
+cache size : 12288 KB
+physical id : 0
+siblings : 6
+core id : 10
+cpu cores : 4
+apicid : 20
+initial apicid : 20
+fpu : yes
+fpu_exception : yes
+cpuid level : 11
+wp : yes
+flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid
+bogomips : 5333.90
+clflush size : 64
+cache_alignment : 64
+address sizes : 40 bits physical, 48 bits virtual
+power management:
+
+processor : 4
+vendor_id : GenuineIntel
+cpu family : 6
+model : 44
+model name : Intel(R) Xeon(R) CPU E5640 @ 2.67GHz
+stepping : 2
+cpu MHz : 1596.000
+cache size : 12288 KB
+physical id : 0
+siblings : 6
+core id : 0
+cpu cores : 4
+apicid : 1
+initial apicid : 1
+fpu : yes
+fpu_exception : yes
+cpuid level : 11
+wp : yes
+flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid
+bogomips : 5333.90
+clflush size : 64
+cache_alignment : 64
+address sizes : 40 bits physical, 48 bits virtual
+power management:
+
+processor : 6
+vendor_id : GenuineIntel
+cpu family : 6
+model : 44
+model name : Intel(R) Xeon(R) CPU E5640 @ 2.67GHz
+stepping : 2
+cpu MHz : 1596.000
+cache size : 12288 KB
+physical id : 0
+siblings : 6
+core id : 9
+cpu cores : 4
+apicid : 19
+initial apicid : 19
+fpu : yes
+fpu_exception : yes
+cpuid level : 11
+wp : yes
+flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid
+bogomips : 5333.90
+clflush size : 64
+cache_alignment : 64
+address sizes : 40 bits physical, 48 bits virtual
+power management:
+
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu0/topology/core_id b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu0/topology/core_id
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu0/topology/core_id
@@ -0,0 +1 @@
+0
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu0/topology/physical_package_id b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu0/topology/physical_package_id
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu0/topology/physical_package_id
@@ -0,0 +1 @@
+0
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu0/topology/thread_siblings b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu0/topology/thread_siblings
new file mode 100644
index 0000000..b4de394
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu0/topology/thread_siblings
@@ -0,0 +1 @@
+11
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu1/online b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu1/online
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu1/online
@@ -0,0 +1 @@
+1
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu1/topology/core_id b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu1/topology/core_id
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu1/topology/core_id
@@ -0,0 +1 @@
+1
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu1/topology/physical_package_id b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu1/topology/physical_package_id
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu1/topology/physical_package_id
@@ -0,0 +1 @@
+0
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu1/topology/thread_siblings b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu1/topology/thread_siblings
new file mode 100644
index 0000000..9e22bcb
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu1/topology/thread_siblings
@@ -0,0 +1 @@
+02
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu2/online b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu2/online
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu2/online
@@ -0,0 +1 @@
+1
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu2/topology/core_id b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu2/topology/core_id
new file mode 100644
index 0000000..ec63514
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu2/topology/core_id
@@ -0,0 +1 @@
+9
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu2/topology/physical_package_id b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu2/topology/physical_package_id
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu2/topology/physical_package_id
@@ -0,0 +1 @@
+0
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu2/topology/thread_siblings b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu2/topology/thread_siblings
new file mode 100644
index 0000000..c739b42
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu2/topology/thread_siblings
@@ -0,0 +1 @@
+44
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu3/online b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu3/online
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu3/online
@@ -0,0 +1 @@
+1
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu3/topology/core_id b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu3/topology/core_id
new file mode 100644
index 0000000..f599e28
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu3/topology/core_id
@@ -0,0 +1 @@
+10
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu3/topology/physical_package_id b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu3/topology/physical_package_id
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu3/topology/physical_package_id
@@ -0,0 +1 @@
+0
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu3/topology/thread_siblings b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu3/topology/thread_siblings
new file mode 100644
index 0000000..adb9de8
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu3/topology/thread_siblings
@@ -0,0 +1 @@
+08
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu4/online b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu4/online
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu4/online
@@ -0,0 +1 @@
+1
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu4/topology/core_id b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu4/topology/core_id
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu4/topology/core_id
@@ -0,0 +1 @@
+0
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu4/topology/physical_package_id b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu4/topology/physical_package_id
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu4/topology/physical_package_id
@@ -0,0 +1 @@
+0
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu4/topology/thread_siblings b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu4/topology/thread_siblings
new file mode 100644
index 0000000..b4de394
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu4/topology/thread_siblings
@@ -0,0 +1 @@
+11
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu5/online b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu5/online
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu5/online
@@ -0,0 +1 @@
+0
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu6/online b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu6/online
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu6/online
@@ -0,0 +1 @@
+1
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu6/topology/core_id b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu6/topology/core_id
new file mode 100644
index 0000000..ec63514
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu6/topology/core_id
@@ -0,0 +1 @@
+9
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu6/topology/physical_package_id b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu6/topology/physical_package_id
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu6/topology/physical_package_id
@@ -0,0 +1 @@
+0
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu6/topology/thread_siblings b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu6/topology/thread_siblings
new file mode 100644
index 0000000..c739b42
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu6/topology/thread_siblings
@@ -0,0 +1 @@
+44
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu7/online b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu7/online
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/cpu/cpu7/online
@@ -0,0 +1 @@
+0
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu0 b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu0
new file mode 120000
index 0000000..c841bea
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu0
@@ -0,0 +1 @@
+../../cpu/cpu0
\ No newline at end of file
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu1 b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu1
new file mode 120000
index 0000000..5f45362
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu1
@@ -0,0 +1 @@
+../../cpu/cpu1
\ No newline at end of file
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu2 b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu2
new file mode 120000
index 0000000..2dcca33
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu2
@@ -0,0 +1 @@
+../../cpu/cpu2
\ No newline at end of file
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu3 b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu3
new file mode 120000
index 0000000..c7690e5
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu3
@@ -0,0 +1 @@
+../../cpu/cpu3
\ No newline at end of file
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu4 b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu4
new file mode 120000
index 0000000..9e77a64
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu4
@@ -0,0 +1 @@
+../../cpu/cpu4
\ No newline at end of file
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu5 b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu5
new file mode 120000
index 0000000..cc07c3b
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu5
@@ -0,0 +1 @@
+../../cpu/cpu5
\ No newline at end of file
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu6 b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu6
new file mode 120000
index 0000000..2e75763
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu6
@@ -0,0 +1 @@
+../../cpu/cpu6
\ No newline at end of file
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu7 b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu7
new file mode 120000
index 0000000..09e3f79
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu7
@@ -0,0 +1 @@
+../../cpu/cpu7
\ No newline at end of file
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/meminfo b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/meminfo
new file mode 100644
index 0000000..8122d41
--- /dev/null
+++ b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/meminfo
@@ -0,0 +1,29 @@
+
+Node 0 MemTotal: 8379620 kB
+Node 0 MemFree: 2971308 kB
+Node 0 MemUsed: 5408312 kB
+Node 0 Active: 3795016 kB
+Node 0 Inactive: 869528 kB
+Node 0 Active(anon): 3081132 kB
+Node 0 Inactive(anon): 13352 kB
+Node 0 Active(file): 713884 kB
+Node 0 Inactive(file): 856176 kB
+Node 0 Unevictable: 48324 kB
+Node 0 Mlocked: 13580 kB
+Node 0 Dirty: 84 kB
+Node 0 Writeback: 0 kB
+Node 0 FilePages: 1585776 kB
+Node 0 Mapped: 134048 kB
+Node 0 AnonPages: 866116 kB
+Node 0 Shmem: 13512 kB
+Node 0 KernelStack: 3904 kB
+Node 0 PageTables: 40664 kB
+Node 0 NFS_Unstable: 0 kB
+Node 0 Bounce: 0 kB
+Node 0 WritebackTmp: 0 kB
+Node 0 Slab: 244404 kB
+Node 0 SReclaimable: 161784 kB
+Node 0 SUnreclaim: 82620 kB
+Node 0 HugePages_Total: 0
+Node 0 HugePages_Free: 0
+Node 0 HugePages_Surp: 0
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/online b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/online
new file mode 100644
index 0000000000000000000000000000000000000000..c1da2e294b3f3646e368cc0056986632de06e2cc
GIT binary patch
literal 3
KcmXruVgLXDrvN(u
literal 0
HcmV?d00001
diff --git a/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/possible b/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/possible
new file mode 100644
index 0000000000000000000000000000000000000000..c1da2e294b3f3646e368cc0056986632de06e2cc
GIT binary patch
literal 3
KcmXruVgLXDrvN(u
literal 0
HcmV?d00001
diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c
index 346af58..851acd0 100644
--- a/tests/nodeinfotest.c
+++ b/tests/nodeinfotest.c
@@ -130,6 +130,7 @@ mymain(void)
"nodeinfo-sysfs-test-3",
"nodeinfo-sysfs-test-4",
"nodeinfo-sysfs-test-5",
+ "nodeinfo-sysfs-test-6",
# endif
};
--
1.7.10.4
2
2
Detected on Cygwin. Broken in commit 387117ad.
* src/util/virnetdev.c (virNetDevValidateConfig): Fix prototype.
---
Pushing under the build-breaker rule.
src/util/virnetdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index cd44bf4..4fd9b00 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -927,7 +927,7 @@ int virNetDevValidateConfig(const char *ifname,
}
#else /* ! HAVE_STRUCT_IFREQ */
int virNetDevValidateConfig(const char *ifname ATTRIBUTE_UNUSED,
- const unsigned char *macaddr ATTRIBUTE_UNUSED,
+ const virMacAddrPtr macaddr ATTRIBUTE_UNUSED,
int ifindex ATTRIBUTE_UNUSED)
{
virReportSystemError(ENOSYS, "%s",
--
1.7.10.4
1
0
I get the following error on Ubuntu 11.04 with current libvirt git HEAD:
$ make check
[...]
CC test-binary-io.o
test-binary-io.c: In function 'main':
test-binary-io.c:54:7: warning: implicit declaration of function
'set_binary_mode'
CCLD test-binary-io
test-binary-io.o: In function `main':
[...]/test-binary-io.c:54: undefined reference to `set_binary_mode'
collect2: ld returned 1 exit status
--
Matthias Bolte
http://photron.blogspot.com
2
2
[libvirt] [PATCH v3] esx: Extend esxVI_CURL_Download for partial downloads
by Matthias Bolte 18 Jul '12
by Matthias Bolte 18 Jul '12
18 Jul '12
Also ensure that the virBuffer used to store the downloaded data
does not overflow.
---
v3:
- Fix virBuffer limit checks.
v2:
- Ensure that the used virBuffer dos not overflow.
src/esx/esx_driver.c | 2 +-
src/esx/esx_vi.c | 62 +++++++++++++++++++++++++++++++++++++++++++------
src/esx/esx_vi.h | 3 +-
3 files changed, 57 insertions(+), 10 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index db2144c..95b9286 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -2802,7 +2802,7 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
url = virBufferContentAndReset(&buffer);
- if (esxVI_CURL_Download(priv->primary->curl, url, &vmx) < 0) {
+ if (esxVI_CURL_Download(priv->primary->curl, url, &vmx, 0, NULL) < 0) {
goto cleanup;
}
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 48718b6..0df973c 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -116,9 +116,9 @@ ESX_VI__TEMPLATE__FREE(CURL,
})
static size_t
-esxVI_CURL_ReadString(char *data, size_t size, size_t nmemb, void *ptrptr)
+esxVI_CURL_ReadString(char *data, size_t size, size_t nmemb, void *userdata)
{
- const char *content = *(const char **)ptrptr;
+ const char *content = *(const char **)userdata;
size_t available = 0;
size_t requested = size * nmemb;
@@ -138,16 +138,28 @@ esxVI_CURL_ReadString(char *data, size_t size, size_t nmemb, void *ptrptr)
memcpy(data, content, requested);
- *(const char **)ptrptr = content + requested;
+ *(const char **)userdata = content + requested;
return requested;
}
static size_t
-esxVI_CURL_WriteBuffer(char *data, size_t size, size_t nmemb, void *buffer)
+esxVI_CURL_WriteBuffer(char *data, size_t size, size_t nmemb, void *userdata)
{
+ virBufferPtr buffer = userdata;
+
if (buffer != NULL) {
- virBufferAdd((virBufferPtr) buffer, data, size * nmemb);
+ /*
+ * Using a virBuffer to store the download data limits the downloadable
+ * size. This is no problem as esxVI_CURL_Download and esxVI_CURL_Perform
+ * are meant to download small things such as VMX files, VMDK metadata
+ * files and SOAP responses.
+ */
+ if (size * nmemb > INT32_MAX / 2 - virBufferUse(buffer)) {
+ return 0;
+ }
+
+ virBufferAdd(buffer, data, size * nmemb);
return size * nmemb;
}
@@ -160,7 +172,7 @@ esxVI_CURL_WriteBuffer(char *data, size_t size, size_t nmemb, void *buffer)
#if ESX_VI__CURL__ENABLE_DEBUG_OUTPUT
static int
esxVI_CURL_Debug(CURL *curl ATTRIBUTE_UNUSED, curl_infotype type,
- char *info, size_t size, void *data ATTRIBUTE_UNUSED)
+ char *info, size_t size, void *userdata ATTRIBUTE_UNUSED)
{
char *buffer = NULL;
@@ -355,8 +367,10 @@ esxVI_CURL_Connect(esxVI_CURL *curl, esxUtil_ParsedUri *parsedUri)
}
int
-esxVI_CURL_Download(esxVI_CURL *curl, const char *url, char **content)
+esxVI_CURL_Download(esxVI_CURL *curl, const char *url, char **content,
+ unsigned long long offset, unsigned long long *length)
{
+ char *range = NULL;
virBuffer buffer = VIR_BUFFER_INITIALIZER;
int responseCode = 0;
@@ -365,9 +379,33 @@ esxVI_CURL_Download(esxVI_CURL *curl, const char *url, char **content)
return -1;
}
+ if (length != NULL && *length > 0) {
+ /*
+ * Using a virBuffer to store the download data limits the downloadable
+ * size. This is no problem as esxVI_CURL_Download is meant to download
+ * small things such as VMX of VMDK metadata files.
+ */
+ if (*length > INT32_MAX / 2) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Download length it too large"));
+ return -1;
+ }
+
+ if (virAsprintf(&range, "%llu-%llu", offset, offset + *length - 1) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ } else if (offset > 0) {
+ if (virAsprintf(&range, "%llu-", offset) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ }
+
virMutexLock(&curl->lock);
curl_easy_setopt(curl->handle, CURLOPT_URL, url);
+ curl_easy_setopt(curl->handle, CURLOPT_RANGE, range);
curl_easy_setopt(curl->handle, CURLOPT_WRITEDATA, &buffer);
curl_easy_setopt(curl->handle, CURLOPT_UPLOAD, 0);
curl_easy_setopt(curl->handle, CURLOPT_HTTPGET, 1);
@@ -378,7 +416,7 @@ esxVI_CURL_Download(esxVI_CURL *curl, const char *url, char **content)
if (responseCode < 0) {
goto cleanup;
- } else if (responseCode != 200) {
+ } else if (responseCode != 200 && responseCode != 206) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
_("HTTP response code %d for download from '%s'"),
responseCode, url);
@@ -390,9 +428,15 @@ esxVI_CURL_Download(esxVI_CURL *curl, const char *url, char **content)
goto cleanup;
}
+ if (length != NULL) {
+ *length = virBufferUse(&buffer);
+ }
+
*content = virBufferContentAndReset(&buffer);
cleanup:
+ VIR_FREE(range);
+
if (*content == NULL) {
virBufferFreeAndReset(&buffer);
return -1;
@@ -414,6 +458,7 @@ esxVI_CURL_Upload(esxVI_CURL *curl, const char *url, const char *content)
virMutexLock(&curl->lock);
curl_easy_setopt(curl->handle, CURLOPT_URL, url);
+ curl_easy_setopt(curl->handle, CURLOPT_RANGE, NULL);
curl_easy_setopt(curl->handle, CURLOPT_READDATA, &content);
curl_easy_setopt(curl->handle, CURLOPT_UPLOAD, 1);
curl_easy_setopt(curl->handle, CURLOPT_INFILESIZE, strlen(content));
@@ -1231,6 +1276,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
virMutexLock(&ctx->curl->lock);
curl_easy_setopt(ctx->curl->handle, CURLOPT_URL, ctx->url);
+ curl_easy_setopt(ctx->curl->handle, CURLOPT_RANGE, NULL);
curl_easy_setopt(ctx->curl->handle, CURLOPT_WRITEDATA, &buffer);
curl_easy_setopt(ctx->curl->handle, CURLOPT_UPLOAD, 0);
curl_easy_setopt(ctx->curl->handle, CURLOPT_POSTFIELDS, request);
diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h
index 9560bd2..49b7ca2 100644
--- a/src/esx/esx_vi.h
+++ b/src/esx/esx_vi.h
@@ -167,7 +167,8 @@ struct _esxVI_CURL {
int esxVI_CURL_Alloc(esxVI_CURL **curl);
void esxVI_CURL_Free(esxVI_CURL **curl);
int esxVI_CURL_Connect(esxVI_CURL *curl, esxUtil_ParsedUri *parsedUri);
-int esxVI_CURL_Download(esxVI_CURL *curl, const char *url, char **content);
+int esxVI_CURL_Download(esxVI_CURL *curl, const char *url, char **content,
+ unsigned long long offset, unsigned long long *length);
int esxVI_CURL_Upload(esxVI_CURL *curl, const char *url, const char *content);
--
1.7.4.1
2
2
18 Jul '12
This series is all about replacing custom error reporting macros
with a common virReportError macro
cfg.mk | 29
po/POTFILES.in | 1
src/conf/cpu_conf.c | 224 +-
src/conf/domain_conf.c | 2347 +++++++++++++++---------------
src/conf/domain_event.c | 32
src/conf/interface_conf.c | 144 -
src/conf/netdev_bandwidth_conf.c | 20
src/conf/netdev_vport_profile_conf.c | 39
src/conf/network_conf.c | 272 +--
src/conf/node_device_conf.c | 142 -
src/conf/node_device_conf.h | 3
src/conf/nwfilter_conf.c | 138 -
src/conf/nwfilter_conf.h | 4
src/conf/nwfilter_params.c | 78
src/conf/secret_conf.c | 58
src/conf/secret_conf.h | 4
src/conf/storage_conf.c | 202 +-
src/conf/storage_conf.h | 4
src/conf/storage_encryption_conf.c | 52
src/conf/virconsole.c | 11
src/interface/netcf_driver.c | 150 -
src/network/bridge_driver.c | 344 ++--
src/node_device/node_device_driver.c | 42
src/node_device/node_device_udev.c | 6
src/nwfilter/nwfilter_dhcpsnoop.c | 149 -
src/nwfilter/nwfilter_driver.c | 3
src/nwfilter/nwfilter_ebiptables_driver.c | 129 -
src/nwfilter/nwfilter_gentech_driver.c | 3
src/nwfilter/nwfilter_learnipaddr.c | 40
src/rpc/virkeepalive.c | 7
src/rpc/virnetclient.c | 51
src/rpc/virnetclientprogram.c | 23
src/rpc/virnetclientstream.c | 19
src/rpc/virnetmessage.c | 49
src/rpc/virnetsaslcontext.c | 130 -
src/rpc/virnetserver.c | 15
src/rpc/virnetserverclient.c | 11
src/rpc/virnetservermdns.c | 17
src/rpc/virnetserverprogram.c | 41
src/rpc/virnetsocket.c | 28
src/rpc/virnettlscontext.c | 265 +--
src/secret/secret_driver.c | 66
src/storage/storage_backend.c | 133 -
src/storage/storage_backend_disk.c | 66
src/storage/storage_backend_fs.c | 162 +-
src/storage/storage_backend_iscsi.c | 94 -
src/storage/storage_backend_logical.c | 40
src/storage/storage_backend_mpath.c | 6
src/storage/storage_backend_rbd.c | 132 -
src/storage/storage_backend_scsi.c | 24
src/storage/storage_driver.c | 386 ++--
src/test/test_driver.c | 32
src/util/command.c | 108 -
src/util/event_poll.c | 10
src/util/hooks.c | 32
src/util/hostusb.c | 20
src/util/iptables.c | 17
src/util/json.c | 25
src/util/pci.c | 64
src/util/sexpr.c | 7
src/util/stats_linux.c | 8
src/util/sysinfo.c | 54
src/util/util.c | 82 -
src/util/virauthconfig.c | 16
src/util/virdbus.c | 18
src/util/virfile.c | 34
src/util/virnetdev.c | 17
src/util/virnetdevmacvlan.c | 15
src/util/virnetdevtap.c | 16
src/util/virnetdevveth.c | 4
src/util/virnetdevvportprofile.c | 35
src/util/virnetlink.c | 26
src/util/virnodesuspend.c | 23
src/util/virrandom.c | 8
src/util/virsocketaddr.c | 13
src/util/virterror_internal.h | 3
src/util/virtypedparam.c | 34
src/util/viruri.c | 9
src/util/xml.c | 50
79 files changed, 3510 insertions(+), 3705 deletions(-)
2
31
[libvirt] We need this patch to mount all tmpfs file systems with the correct context.
by Daniel J Walsh 18 Jul '12
by Daniel J Walsh 18 Jul '12
18 Jul '12
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Basically within a Secure Linux Container (virt-sandbox) we want all content
that the process within the container can write to be labeled the same. We
are labeling the physical disk correctly but when we create "RAM" based file
systems
libvirt is not labeling them, and they are defaulting to tmpfs_t, which will
will not allow the processes to write. This patch labels the RAM based file
systems correctly.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAlAFiTwACgkQrlYvE4MpobPA1ACghFq3nxmNmHP/WEq1vSwjtoin
VFoAnAlxgPISuIPiAPSFUL0CjiiSXDzw
=xFCU
-----END PGP SIGNATURE-----
3
7
18 Jul '12
This patch brings support to manage sheepdog pools and volumes to libvirt.
It uses the "collie" command-line utility that comes with sheepdog for that.
A sheepdog pool in libvirt maps to a sheepdog cluster.
It needs a host and port to connect to, which in most cases
is just going to be the default of localhost on port 7000.
A sheepdog volume in libvirt maps to a sheepdog vdi.
To create one specify the pool, a name and the capacity.
Volumes can also be resized later.
In the volume XML the vdi name has to be put into the <target><path>.
To use the volume as a disk source for virtual machines specify
the vdi name as "name" attribute of the <source>.
The host and port information from the pool are specified inside the host tag.
<disk type='network'>
...
<source protocol="sheepdog" name="vdi_name">
<host name="localhost" port="7000"/>
</source>
</disk>
To work right this patch parses the output of collie,
so it relies on the raw output option. There recently was a bug which caused
size information to be reported wrong. This is fixed upstream already and
will be in the next release.
Signed-off-by: Sebastian Wiedenroth <wiedi(a)frubar.net>
---
.gitignore | 1 +
configure.ac | 32 +++
docs/drivers.html.in | 1 +
docs/schemas/storagepool.rng | 17 ++
docs/schemas/storagevol.rng | 3 +-
docs/storage.html.in | 62 +++++
libvirt.spec.in | 35 ++-
po/POTFILES.in | 1 +
src/Makefile.am | 8 +
src/conf/storage_conf.c | 19 +-
src/conf/storage_conf.h | 1 +
src/storage/storage_backend.c | 6 +
src/storage/storage_backend_sheepdog.c | 311 +++++++++++++++++++++++++
src/storage/storage_backend_sheepdog.h | 39 ++++
tests/Makefile.am | 13 ++
tests/storagebackendsheepdogtest.c | 214 +++++++++++++++++
tests/storagepoolxml2xmlin/pool-sheepdog.xml | 8 +
tests/storagepoolxml2xmlout/pool-sheepdog.xml | 11 +
tests/storagepoolxml2xmltest.c | 1 +
tests/storagevolxml2xmlin/vol-sheepdog.xml | 10 +
tests/storagevolxml2xmlout/vol-sheepdog.xml | 17 ++
tests/storagevolxml2xmltest.c | 1 +
tools/virsh.c | 3 +
23 files changed, 799 insertions(+), 15 deletions(-)
create mode 100644 src/storage/storage_backend_sheepdog.c
create mode 100644 src/storage/storage_backend_sheepdog.h
create mode 100644 tests/storagebackendsheepdogtest.c
create mode 100644 tests/storagepoolxml2xmlin/pool-sheepdog.xml
create mode 100644 tests/storagepoolxml2xmlout/pool-sheepdog.xml
create mode 100644 tests/storagevolxml2xmlin/vol-sheepdog.xml
create mode 100644 tests/storagevolxml2xmlout/vol-sheepdog.xml
diff --git a/.gitignore b/.gitignore
index cd978d2..098ba09 100644
--- a/.gitignore
+++ b/.gitignore
@@ -145,6 +145,7 @@
/tests/sockettest
/tests/ssh
/tests/statstest
+/tests/storagebackendsheepdogtest
/tests/utiltest
/tests/virauthconfigtest
/tests/virbuftest
diff --git a/configure.ac b/configure.ac
index c0ef9b1..13aa0e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1825,6 +1825,8 @@ AC_ARG_WITH([storage-disk],
AC_HELP_STRING([--with-storage-disk], [with GPartd Disk backend for the storage driver @<:@default=check@:>@]),[],[with_storage_disk=check])
AC_ARG_WITH([storage-rbd],
AC_HELP_STRING([--with-storage-rbd], [with RADOS Block Device backend for the storage driver @<:@default=check@:>@]),[],[with_storage_rbd=check])
+AC_ARG_WITH([storage-sheepdog],
+ AC_HELP_STRING([--with-storage-sheepdog], [with Sheepdog backend for the storage driver @<:@default=check@:>@]),[],[with_storage_sheepdog=check])
if test "$with_libvirtd" = "no"; then
with_storage_dir=no
@@ -1835,6 +1837,7 @@ if test "$with_libvirtd" = "no"; then
with_storage_mpath=no
with_storage_disk=no
with_storage_rbd=no
+ with_storage_sheepdog=no
fi
if test "$with_storage_dir" = "yes" ; then
AC_DEFINE_UNQUOTED([WITH_STORAGE_DIR], 1, [whether directory backend for storage driver is enabled])
@@ -2009,6 +2012,34 @@ fi
AM_CONDITIONAL([WITH_STORAGE_RBD], [test "$with_storage_rbd" = "yes"])
AC_SUBST([LIBRBD_LIBS])
+if test "$with_storage_sheepdog" = "yes" ||
+ test "$with_storage_sheepdog" = "check"; then
+ AC_PATH_PROG([COLLIE], [collie], [], [$PATH:/sbin:/usr/sbin])
+
+ if test "$with_storage_sheepdog" = "yes"; then
+ if test -z "$COLLIE"; then
+ AC_MSG_ERROR([We need collie for Sheepdog storage driver])
+ fi
+ else
+ if test -z "$COLLIE"; then
+ with_storage_sheepdog=no
+ fi
+
+ if test "$with_storage_sheepdog" = "check"; then
+ with_storage_sheepdog=yes
+ fi
+ fi
+
+ if test "$with_storage_sheepdog" = "yes"; then
+ AC_DEFINE_UNQUOTED([WITH_STORAGE_SHEEPDOG], 1,
+ [whether Sheepdog backend for storage driver is enabled])
+ AC_DEFINE_UNQUOTED([COLLIE],["$COLLIE"],[Location of collie program])
+ fi
+fi
+AM_CONDITIONAL([WITH_STORAGE_SHEEPDOG],
+ [test "$with_storage_sheepdog" = "yes"])
+
+
LIBPARTED_CFLAGS=
LIBPARTED_LIBS=
if test "$with_storage_disk" = "yes" ||
@@ -2824,6 +2855,7 @@ AC_MSG_NOTICE([ SCSI: $with_storage_scsi])
AC_MSG_NOTICE([ mpath: $with_storage_mpath])
AC_MSG_NOTICE([ Disk: $with_storage_disk])
AC_MSG_NOTICE([ RBD: $with_storage_rbd])
+AC_MSG_NOTICE([Sheepdog: $with_storage_sheepdog])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([Security Drivers])
AC_MSG_NOTICE([])
diff --git a/docs/drivers.html.in b/docs/drivers.html.in
index 8ad2c33..90b6196 100644
--- a/docs/drivers.html.in
+++ b/docs/drivers.html.in
@@ -43,6 +43,7 @@
<li><strong><a href="storage.html#StorageBackendSCSI">SCSI backend</a></strong></li>
<li><strong><a href="storage.html#StorageBackendMultipath">Multipath backend</a></strong></li>
<li><strong><a href="storage.html#StorageBackendRBD">RBD (RADOS Block Device) backend</a></strong></li>
+ <li><strong><a href="storage.html#StorageBackendSheepdog">Sheepdog backend</a></strong></li>
</ul>
</body>
</html>
diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng
index 75b6b51..039798a 100644
--- a/docs/schemas/storagepool.rng
+++ b/docs/schemas/storagepool.rng
@@ -20,6 +20,7 @@
<ref name='poolscsi'/>
<ref name='poolmpath'/>
<ref name='poolrbd'/>
+ <ref name='poolsheepdog'/>
</choice>
</element>
</define>
@@ -115,6 +116,15 @@
<ref name='sourcerbd'/>
</define>
+ <define name='poolsheepdog'>
+ <attribute name='type'>
+ <value>sheepdog</value>
+ </attribute>
+ <ref name='commonmetadata'/>
+ <ref name='sizing'/>
+ <ref name='sourcesheepdog'/>
+ </define>
+
<define name='sourceinfovendor'>
<optional>
<element name='vendor'>
@@ -496,6 +506,13 @@
</element>
</define>
+ <define name='sourcesheepdog'>
+ <element name='source'>
+ <ref name='sourceinfohost'/>
+ <ref name='sourceinfoname'/>
+ </element>
+ </define>
+
<define name='name'>
<data type='string'>
<param name="pattern">[a-zA-Z0-9_\+\-]+</param>
diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng
index 7a74331..0b9933d 100644
--- a/docs/schemas/storagevol.rng
+++ b/docs/schemas/storagevol.rng
@@ -67,7 +67,7 @@
<element name='target'>
<optional>
<element name='path'>
- <ref name='absFilePath'/>
+ <data type='anyURI'/>
</element>
</optional>
<ref name='format'/>
@@ -144,6 +144,7 @@
<define name='formatfile'>
<choice>
+ <value>unknown</value>
<value>raw</value>
<value>dir</value>
<value>bochs</value>
diff --git a/docs/storage.html.in b/docs/storage.html.in
index b3484e8..26a949a 100644
--- a/docs/storage.html.in
+++ b/docs/storage.html.in
@@ -110,6 +110,9 @@
<li>
<a href="#StorageBackendRBD">RBD (RADOS Block Device) backend</a>
</li>
+ <li>
+ <a href="#StorageBackendSheepdog">Sheepdog backend</a>
+ </li>
</ul>
<h2><a name="StorageBackendDir">Directory pool</a></h2>
@@ -565,5 +568,64 @@
The RBD pool does not use the volume format type element.
</p>
+ <h2><a name="StorageBackendSheepdog">Sheepdog pools</a></h2>
+ <p>
+ This provides a pool based on a Sheepdog Cluster.
+ Sheepdog is a distributed storage system for QEMU/KVM.
+ It provides highly available block level storage volumes that
+ can be attached to QEMU/KVM virtual machines.
+
+ The cluster must already be formatted.
+
+ <span class="since">Since 0.9.13</span>
+ </p>
+
+ <h3>Example pool input</h3>
+ <pre>
+ <pool type="sheepdog">
+ <name>mysheeppool</name>
+ <source>
+ <name>mysheeppool</name>
+ <host name='localhost' port='7000'/>
+ </source>
+ </pool></pre>
+
+ <h3>Example volume output</h3>
+ <pre>
+ <volume>
+ <name>myvol</name>
+ <key>sheep/myvol</key>
+ <source>
+ </source>
+ <capacity unit='bytes'>53687091200</capacity>
+ <allocation unit='bytes'>53687091200</allocation>
+ <target>
+ <path>sheepdog:myvol</path>
+ <format type='unknown'/>
+ <permissions>
+ <mode>00</mode>
+ <owner>0</owner>
+ <group>0</group>
+ </permissions>
+ </target>
+ </volume></pre>
+
+ <h3>Example disk attachment</h3>
+ <p>Sheepdog images can be attached to Qemu guests.
+ Information about attaching a Sheepdog image to a
+ guest can be found
+ at the <a href="formatdomain.html#elementsDisks">format domain</a>
+ page.</p>
+
+ <h3>Valid pool format types</h3>
+ <p>
+ The Sheepdog pool does not use the pool format type element.
+ </p>
+
+ <h3>Valid volume format types</h3>
+ <p>
+ The Sheepdog pool does not use the volume format type element.
+ </p>
+
</body>
</html>
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 896ef51..e80259e 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -69,19 +69,24 @@
%define with_xenapi 0%{!?_without_xenapi:1}
# Then the secondary host drivers, which run inside libvirtd
-%define with_network 0%{!?_without_network:%{server_drivers}}
-%define with_storage_fs 0%{!?_without_storage_fs:%{server_drivers}}
-%define with_storage_lvm 0%{!?_without_storage_lvm:%{server_drivers}}
-%define with_storage_iscsi 0%{!?_without_storage_iscsi:%{server_drivers}}
-%define with_storage_disk 0%{!?_without_storage_disk:%{server_drivers}}
-%define with_storage_mpath 0%{!?_without_storage_mpath:%{server_drivers}}
+%define with_network 0%{!?_without_network:%{server_drivers}}
+%define with_storage_fs 0%{!?_without_storage_fs:%{server_drivers}}
+%define with_storage_lvm 0%{!?_without_storage_lvm:%{server_drivers}}
+%define with_storage_iscsi 0%{!?_without_storage_iscsi:%{server_drivers}}
+%define with_storage_disk 0%{!?_without_storage_disk:%{server_drivers}}
+%define with_storage_mpath 0%{!?_without_storage_mpath:%{server_drivers}}
%if 0%{?fedora} >= 16
-%define with_storage_rbd 0%{!?_without_storage_rbd:%{server_drivers}}
+%define with_storage_rbd 0%{!?_without_storage_rbd:%{server_drivers}}
%else
-%define with_storage_rbd 0
+%define with_storage_rbd 0
%endif
-%define with_numactl 0%{!?_without_numactl:%{server_drivers}}
-%define with_selinux 0%{!?_without_selinux:%{server_drivers}}
+%if 0%{?fedora} >= 17
+%define with_storage_sheepdog 0%{!?_without_storage_sheepdog:%{server_drivers}}
+%else
+%define with_storage_sheepdog 0
+%endif
+%define with_numactl 0%{!?_without_numactl:%{server_drivers}}
+%define with_selinux 0%{!?_without_selinux:%{server_drivers}}
# A few optional bits off by default, we enable later
%define with_polkit 0%{!?_without_polkit:0}
@@ -224,6 +229,7 @@
%define with_storage_iscsi 0
%define with_storage_mpath 0
%define with_storage_rbd 0
+%define with_storage_sheepdog 0
%define with_storage_disk 0
%endif
@@ -603,6 +609,10 @@ Requires: device-mapper
# For RBD support
Requires: ceph
%endif
+%if %{with_storage_sheepdog}
+# For Sheepdog support
+Requires: sheepdog
+%endif
%if %{with_cgconfig}
Requires: libcgroup
%endif
@@ -1080,6 +1090,10 @@ of recent versions of Linux (and other OSes).
%define _without_storage_rbd --without-storage-rbd
%endif
+%if ! %{with_storage_sheepdog}
+%define _without_storage_sheepdog --without-storage-sheepdog
+%endif
+
%if ! %{with_numactl}
%define _without_numactl --without-numactl
%endif
@@ -1178,6 +1192,7 @@ autoreconf -if
%{?_without_storage_disk} \
%{?_without_storage_mpath} \
%{?_without_storage_rbd} \
+ %{?_without_storage_sheepdog} \
%{?_without_numactl} \
%{?_without_numad} \
%{?_without_capng} \
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 31246f7..33a2ace 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -108,6 +108,7 @@ src/storage/storage_backend_logical.c
src/storage/storage_backend_mpath.c
src/storage/storage_backend_rbd.c
src/storage/storage_backend_scsi.c
+src/storage/storage_backend_sheepdog.c
src/storage/storage_driver.c
src/test/test_driver.c
src/uml/uml_conf.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 2309984..7effcd6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -515,6 +515,9 @@ STORAGE_DRIVER_DISK_SOURCES = \
STORAGE_DRIVER_RBD_SOURCES = \
storage/storage_backend_rbd.h storage/storage_backend_rbd.c
+STORAGE_DRIVER_SHEEPDOG_SOURCES = \
+ storage/storage_backend_sheepdog.h storage/storage_backend_sheepdog.c
+
STORAGE_HELPER_DISK_SOURCES = \
storage/parthelper.c
@@ -1019,6 +1022,10 @@ libvirt_driver_storage_la_SOURCES += $(STORAGE_DRIVER_RBD_SOURCES)
libvirt_driver_storage_la_LIBADD += $(LIBRBD_LIBS)
endif
+if WITH_STORAGE_SHEEPDOG
+libvirt_driver_storage_la_SOURCES += $(STORAGE_DRIVER_SHEEPDOG_SOURCES)
+endif
+
if WITH_NODE_DEVICES
# Needed to keep automake quiet about conditionals
if WITH_DRIVER_MODULES
@@ -1117,6 +1124,7 @@ EXTRA_DIST += \
$(STORAGE_DRIVER_MPATH_SOURCES) \
$(STORAGE_DRIVER_DISK_SOURCES) \
$(STORAGE_DRIVER_RBD_SOURCES) \
+ $(STORAGE_DRIVER_SHEEPDOG_SOURCES) \
$(NODE_DEVICE_DRIVER_SOURCES) \
$(NODE_DEVICE_DRIVER_HAL_SOURCES) \
$(NODE_DEVICE_DRIVER_UDEV_SOURCES) \
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index bf4567f..cd17db6 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -52,7 +52,7 @@ VIR_ENUM_IMPL(virStoragePool,
VIR_STORAGE_POOL_LAST,
"dir", "fs", "netfs",
"logical", "disk", "iscsi",
- "scsi", "mpath", "rbd")
+ "scsi", "mpath", "rbd", "sheepdog")
VIR_ENUM_IMPL(virStoragePoolFormatFileSystem,
VIR_STORAGE_POOL_FS_LAST,
@@ -206,6 +206,17 @@ static virStoragePoolTypeInfo poolTypeInfo[] = {
.formatToString = virStoragePoolFormatDiskTypeToString,
}
},
+ { .poolType = VIR_STORAGE_POOL_SHEEPDOG,
+ .poolOptions = {
+ .flags = (VIR_STORAGE_POOL_SOURCE_HOST |
+ VIR_STORAGE_POOL_SOURCE_NETWORK |
+ VIR_STORAGE_POOL_SOURCE_NAME),
+ },
+ .volOptions = {
+ .defaultFormat = VIR_STORAGE_FILE_RAW,
+ .formatToString = virStoragePoolFormatDiskTypeToString,
+ }
+ },
{ .poolType = VIR_STORAGE_POOL_MPATH,
.volOptions = {
.formatToString = virStoragePoolFormatDiskTypeToString,
@@ -1011,9 +1022,9 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def) {
if (virStoragePoolSourceFormat(&buf, options, &def->source) < 0)
goto cleanup;
- /* RBD devices are not local block devs nor files, so it doesn't
+ /* RBD and Sheepdog devices are not local block devs nor files, so it doesn't
* have a target */
- if (def->type != VIR_STORAGE_POOL_RBD) {
+ if (def->type != VIR_STORAGE_POOL_RBD && def->type != VIR_STORAGE_POOL_SHEEPDOG) {
virBufferAddLit(&buf," <target>\n");
if (def->target.path)
@@ -1296,7 +1307,7 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
virBufferAddLit(&buf, "<volume>\n");
virBufferAsprintf(&buf," <name>%s</name>\n", def->name);
- virBufferAsprintf(&buf," <key>%s</key>\n", def->key);
+ virBufferAsprintf(&buf," <key>%s</key>\n", def->key ? def->key : "(null)");
virBufferAddLit(&buf, " <source>\n");
if (def->source.nextent) {
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index 5733b57..dcf976f 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -121,6 +121,7 @@ enum virStoragePoolType {
VIR_STORAGE_POOL_SCSI, /* SCSI HBA */
VIR_STORAGE_POOL_MPATH, /* Multipath devices */
VIR_STORAGE_POOL_RBD, /* RADOS Block Device */
+ VIR_STORAGE_POOL_SHEEPDOG, /* Sheepdog device */
VIR_STORAGE_POOL_LAST,
};
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index e2e9b51..93964d6 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -80,6 +80,9 @@
#if WITH_STORAGE_RBD
# include "storage_backend_rbd.h"
#endif
+#if WITH_STORAGE_SHEEPDOG
+# include "storage_backend_sheepdog.h"
+#endif
#define VIR_FROM_THIS VIR_FROM_STORAGE
@@ -109,6 +112,9 @@ static virStorageBackendPtr backends[] = {
#if WITH_STORAGE_RBD
&virStorageBackendRBD,
#endif
+#if WITH_STORAGE_SHEEPDOG
+ &virStorageBackendSheepdog,
+#endif
NULL
};
diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c
new file mode 100644
index 0000000..68633d4
--- /dev/null
+++ b/src/storage/storage_backend_sheepdog.c
@@ -0,0 +1,311 @@
+/*
+ * storage_backend_sheepdog.c: storage backend for Sheepdog handling
+ *
+ * Copyright (C) 2012 Wido den Hollander
+ * Copyright (C) 2012 Frank Spijkerman
+ * Copyright (C) 2012 Sebastian Wiedenroth
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Wido den Hollander <wido(a)widodh.nl>
+ * Frank Spijkerman <frank.spijkerman(a)avira.com>
+ * Sebastian Wiedenroth <sebastian.wiedenroth(a)skylime.net>
+ */
+
+#include <config.h>
+
+#include "virterror_internal.h"
+#include "storage_backend_sheepdog.h"
+#include "storage_conf.h"
+#include "util/command.h"
+#include "util.h"
+#include "memory.h"
+#include "logging.h"
+
+#define VIR_FROM_THIS VIR_FROM_STORAGE
+
+static int virStorageBackendSheepdogRefreshVol(virConnectPtr conn,
+ virStoragePoolObjPtr pool,
+ virStorageVolDefPtr vol);
+
+void virStorageBackendSheepdogAddHostArg(virCommandPtr cmd,
+ virStoragePoolObjPtr pool);
+
+int
+virStorageBackendSheepdogParseNodeInfo(virStoragePoolDefPtr pool,
+ char *output)
+{
+ /* fields:
+ * node id/total, size, used, use%, [total vdi size]
+ *
+ * example output:
+ * 0 15245667872 117571104 0%
+ * Total 15245667872 117571104 0% 20972341
+ */
+
+ const char *p, *next;
+
+ pool->allocation = pool->capacity = pool->available = 0;
+
+ p = output;
+ do {
+ char *end;
+
+ if ((next = strchr(p, '\n')))
+ ++next;
+ else
+ return -1;
+
+ if (!STRPREFIX(p, "Total "))
+ continue;
+
+ p = p + 6;
+
+ if (virStrToLong_ull(p, &end, 10, &pool->capacity) < 0)
+ return -1;
+
+ if ((p = end + 1) > next)
+ return -1;
+
+ if (virStrToLong_ull(p, &end, 10, &pool->allocation) < 0)
+ return -1;
+
+ pool->available = pool->capacity - pool->allocation;
+ return 0;
+
+ } while ((p = next));
+
+ return -1;
+}
+
+void
+virStorageBackendSheepdogAddHostArg(virCommandPtr cmd,
+ virStoragePoolObjPtr pool)
+{
+ const char *address = "localhost";
+ int port = 7000;
+ if (pool->def->source.nhost > 0) {
+ if (pool->def->source.hosts[0].name != NULL) {
+ address = pool->def->source.hosts[0].name;
+ }
+ if (pool->def->source.hosts[0].port) {
+ port = pool->def->source.hosts[0].port;
+ }
+ }
+ virCommandAddArg(cmd, "-a");
+ virCommandAddArgFormat(cmd, "%s", address);
+ virCommandAddArg(cmd, "-p");
+ virCommandAddArgFormat(cmd, "%d", port);
+}
+
+
+static int
+virStorageBackendSheepdogRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virStoragePoolObjPtr pool)
+{
+ int ret;
+ char *output = NULL;
+ virCommandPtr cmd;
+
+ cmd = virCommandNewArgList(COLLIE, "node", "info", "-r", NULL);
+ virStorageBackendSheepdogAddHostArg(cmd, pool);
+ virCommandSetOutputBuffer(cmd, &output);
+ ret = virCommandRun(cmd, NULL);
+ if (ret == 0)
+ ret = virStorageBackendSheepdogParseNodeInfo(pool->def, output);
+
+ virCommandFree(cmd);
+ VIR_FREE(output);
+ return ret;
+}
+
+
+static int
+virStorageBackendSheepdogDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virStoragePoolObjPtr pool,
+ virStorageVolDefPtr vol,
+ unsigned int flags)
+{
+
+ virCheckFlags(0, -1);
+
+ virCommandPtr cmd = virCommandNewArgList(COLLIE, "vdi", "delete", vol->name, NULL);
+ virStorageBackendSheepdogAddHostArg(cmd, pool);
+ int ret = virCommandRun(cmd, NULL);
+
+ virCommandFree(cmd);
+ return ret;
+}
+
+
+static int
+virStorageBackendSheepdogCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virStoragePoolObjPtr pool,
+ virStorageVolDefPtr vol)
+{
+
+ int ret;
+
+ if (vol->target.encryption != NULL) {
+ virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Sheepdog does not support encrypted volumes"));
+ return -1;
+ }
+
+ virCommandPtr cmd = virCommandNewArgList(COLLIE, "vdi", "create", vol->name, NULL);
+ virCommandAddArgFormat(cmd, "%llu", vol->capacity);
+ virStorageBackendSheepdogAddHostArg(cmd, pool);
+ ret = virCommandRun(cmd, NULL);
+
+ virStorageBackendSheepdogRefreshVol(conn, pool, vol);
+
+ virCommandFree(cmd);
+ return ret;
+}
+
+
+int
+virStorageBackendSheepdogParseVdiList(virStorageVolDefPtr vol,
+ char *output)
+{
+ /* fields:
+ * current/clone/snapshot, name, id, size, used, shared, creation time, vdi id, [tag]
+ *
+ * example output:
+ * s test 1 10 0 0 1336556634 7c2b25
+ * s test 2 10 0 0 1336557203 7c2b26
+ * = test 3 10 0 0 1336557216 7c2b27
+ */
+
+ int id;
+ const char *p, *next;
+
+ vol->allocation = vol->capacity = 0;
+
+ p = output;
+ do {
+ char *end;
+
+ if ((next = strchr(p, '\n')))
+ ++next;
+
+ /* ignore snapshots */
+ if (*p != '=')
+ continue;
+
+ /* skip space */
+ if (p + 2 < next) {
+ p += 2;
+ } else {
+ return -1;
+ }
+
+ /* skip name */
+ while (*p != '\0' && *p != ' ') {
+ if (*p == '\\')
+ ++p;
+ ++p;
+ }
+
+ if (virStrToLong_i(p, &end, 10, &id) < 0)
+ return -1;
+
+ p = end + 1;
+
+ if (virStrToLong_ull(p, &end, 10, &vol->capacity) < 0)
+ return -1;
+
+ p = end + 1;
+
+ if (virStrToLong_ull(p, &end, 10, &vol->allocation) < 0)
+ return -1;
+
+ return 0;
+ } while ((p = next));
+
+ return -1;
+}
+
+static int
+virStorageBackendSheepdogRefreshVol(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virStoragePoolObjPtr pool,
+ virStorageVolDefPtr vol)
+{
+ int ret;
+ char *output = NULL;
+
+ virCommandPtr cmd = virCommandNewArgList(COLLIE, "vdi", "list", vol->name, "-r", NULL);
+ virStorageBackendSheepdogAddHostArg(cmd, pool);
+ virCommandSetOutputBuffer(cmd, &output);
+ ret = virCommandRun(cmd, NULL);
+
+ if (ret < 0)
+ goto cleanup;
+
+ if ((ret = virStorageBackendSheepdogParseVdiList(vol, output)) < 0)
+ goto cleanup;
+
+ vol->type = VIR_STORAGE_VOL_NETWORK;
+
+ VIR_FREE(vol->key);
+ if (virAsprintf(&vol->key, "%s/%s",
+ pool->def->source.name, vol->name) == -1) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ VIR_FREE(vol->target.path);
+ if (virAsprintf(&vol->target.path, "%s", vol->name) == -1) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+cleanup:
+ virCommandFree(cmd);
+ return ret;
+}
+
+
+static int
+virStorageBackendSheepdogResizeVol(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virStoragePoolObjPtr pool,
+ virStorageVolDefPtr vol,
+ unsigned long long capacity,
+ unsigned int flags)
+{
+
+ virCheckFlags(0, -1);
+
+ virCommandPtr cmd = virCommandNewArgList(COLLIE, "vdi", "resize", vol->name, NULL);
+ virCommandAddArgFormat(cmd, "%llu", capacity);
+ virStorageBackendSheepdogAddHostArg(cmd, pool);
+ int ret = virCommandRun(cmd, NULL);
+
+ virCommandFree(cmd);
+ return ret;
+
+}
+
+
+
+virStorageBackend virStorageBackendSheepdog = {
+ .type = VIR_STORAGE_POOL_SHEEPDOG,
+
+ .refreshPool = virStorageBackendSheepdogRefreshPool,
+ .createVol = virStorageBackendSheepdogCreateVol,
+ .refreshVol = virStorageBackendSheepdogRefreshVol,
+ .deleteVol = virStorageBackendSheepdogDeleteVol,
+ .resizeVol = virStorageBackendSheepdogResizeVol,
+};
diff --git a/src/storage/storage_backend_sheepdog.h b/src/storage/storage_backend_sheepdog.h
new file mode 100644
index 0000000..51ef7a4
--- /dev/null
+++ b/src/storage/storage_backend_sheepdog.h
@@ -0,0 +1,39 @@
+/*
+ * storage_backend_sheepog.h: storage backend for Sheepdog handling
+ *
+ * Copyright (C) 2012 Wido den Hollander
+ * Copyright (C) 2012 Frank Spijkerman
+ * Copyright (C) 2012 Sebastian Wiedenroth
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Wido den Hollander <wido(a)widodh.nl>
+ * Frank Spijkerman <frank.spijkerman(a)avira.com>
+ * Sebastian Wiedenroth <sebastian.wiedenroth(a)skylime.net>
+ */
+
+#ifndef __VIR_STORAGE_BACKEND_SHEEPDOG_H__
+# define __VIR_STORAGE_BACKEND_SHEEPDOG_H__
+
+# include "storage_backend.h"
+
+int virStorageBackendSheepdogParseNodeInfo(virStoragePoolDefPtr pool,
+ char *output);
+int virStorageBackendSheepdogParseVdiList(virStorageVolDefPtr vol,
+ char *output);
+
+extern virStorageBackend virStorageBackendSheepdog;
+
+#endif /* __VIR_STORAGE_BACKEND_SHEEPDOG_H__ */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e3bd6d1..a466480 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -141,6 +141,10 @@ if WITH_NETWORK
test_programs += networkxml2argvtest
endif
+if WITH_STORAGE_SHEEPDOG
+test_programs += storagebackendsheepdogtest
+endif
+
test_programs += nwfilterxml2xmltest
test_programs += storagevolxml2xmltest storagepoolxml2xmltest
@@ -398,6 +402,15 @@ else
EXTRA_DIST += networkxml2argvtest.c
endif
+if WITH_STORAGE_SHEEPDOG
+storagebackendsheepdogtest_SOURCES = \
+ storagebackendsheepdogtest.c \
+ testutils.c testutils.h
+storagebackendsheepdogtest_LDADD = ../src/libvirt_driver_storage.la $(LDADDS)
+else
+EXTRA_DIST += storagebackendsheepdogtest.c
+endif
+
nwfilterxml2xmltest_SOURCES = \
nwfilterxml2xmltest.c \
testutils.c testutils.h
diff --git a/tests/storagebackendsheepdogtest.c b/tests/storagebackendsheepdogtest.c
new file mode 100644
index 0000000..0870829
--- /dev/null
+++ b/tests/storagebackendsheepdogtest.c
@@ -0,0 +1,214 @@
+/*
+ * storagebackendsheepdogtest.c: storage backend for Sheepdog handling
+ *
+ * Copyright (C) 2012 Sebastian Wiedenroth
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Sebastian Wiedenroth <sebastian.wiedenroth(a)skylime.net>
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <fcntl.h>
+
+#include "internal.h"
+#include "testutils.h"
+#include "storage/storage_backend_sheepdog.h"
+
+
+typedef struct {
+ const char *output;
+ int expected_return;
+ uint64_t expected_capacity;
+ uint64_t expected_allocation;
+} collie_test;
+
+
+static int
+test_node_info_parser(collie_test test, char *poolxml)
+{
+ int ret = -1;
+ char *output = NULL;
+ char *poolXmlData = NULL;
+ virStoragePoolDefPtr pool = NULL;
+
+ if (virtTestLoadFile(poolxml, &poolXmlData) < 0)
+ goto cleanup;
+
+ if (!(pool = virStoragePoolDefParseString(poolXmlData)))
+ goto cleanup;
+
+ output = strdup(test.output);
+ if (!output)
+ goto cleanup;
+
+ if (virStorageBackendSheepdogParseNodeInfo(pool, output) !=
+ test.expected_return)
+ goto cleanup;
+
+ if (test.expected_return) {
+ ret = 0;
+ goto cleanup;
+ }
+
+ if (pool->capacity == test.expected_capacity &&
+ pool->allocation == test.expected_allocation)
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(output);
+ VIR_FREE(poolXmlData);
+ virStoragePoolDefFree(pool);
+ return ret;
+}
+
+static int
+test_vdi_list_parser(collie_test test, char *poolxml, char *volxml)
+{
+ int ret = -1;
+ char *poolXmlData = NULL;
+ char *volXmlData = NULL;
+ char *output = NULL;
+ virStoragePoolDefPtr pool = NULL;
+ virStorageVolDefPtr vol = NULL;
+
+ if (virtTestLoadFile(poolxml, &poolXmlData) < 0)
+ goto cleanup;
+ if (virtTestLoadFile(volxml, &volXmlData) < 0)
+ goto cleanup;
+
+ if (!(pool = virStoragePoolDefParseString(poolXmlData)))
+ goto cleanup;
+
+ if (!(vol = virStorageVolDefParseString(pool, volXmlData)))
+ goto cleanup;
+
+ output = strdup(test.output);
+ if (!output)
+ goto cleanup;
+
+ if (virStorageBackendSheepdogParseVdiList(vol, output) !=
+ test.expected_return)
+ goto cleanup;
+
+ if (test.expected_return) {
+ ret = 0;
+ goto cleanup;
+ }
+
+ if (vol->capacity == test.expected_capacity &&
+ vol->allocation == test.expected_allocation)
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(output);
+ VIR_FREE(poolXmlData);
+ VIR_FREE(volXmlData);
+ virStoragePoolDefFree(pool);
+ virStorageVolDefFree(vol);
+ return ret;
+}
+
+
+static int
+mymain(void)
+{
+ int ret = -1;
+ char *poolxml = NULL;
+ char *volxml = NULL;
+
+ collie_test node_info_tests[] = {
+ {"", -1, 0, 0},
+ {"Total 15245667872 117571104 0% 20972341\n", 0, 15245667872, 117571104},
+ {"To", -1, 0, 0},
+ {"asdf\nasdf", -1, 0, 0},
+ {"Total ", -1, 0, 0},
+ {"Total 1", -1, 0, 0},
+ {"Total 1\n", -1, 0, 0},
+ {"Total 1 ", -1, 0, 0},
+ {"Total 1 2", -1, 0, 0},
+ {"Total 1 2 ", -1, 0, 0},
+ {"Total 1 2\n", 0, 1, 2},
+ {"Total 1 2 \n", 0, 1, 2},
+ {"Total a 2 \n", -1, 0, 0},
+ {"Total 1 b \n", -1, 0, 0},
+ {"Total a b \n", -1, 0, 0},
+ {"stuff\nTotal 1 2 \n", 0, 1, 2},
+ {"0 1 2 3\nTotal 1 2 \n", 0, 1, 2},
+ {NULL, 0, 0, 0}
+ };
+
+ collie_test vdi_list_tests[] = {
+ {"", -1, 0, 0},
+ {"= test 3 10 20 0 1336557216 7c2b27\n", 0, 10, 20},
+ {"= test\\ with\\ spaces 3 10 20 0 1336557216 7c2b27\n", 0, 10, 20},
+ {"= backslashattheend\\\\ 3 10 20 0 1336557216 7c2b27\n", 0, 10, 20},
+ {"s test 1 10 20 0 1336556634 7c2b25\n= test 3 50 60 0 1336557216 7c2b27\n", 0, 50, 60},
+ {"=", -1, 0, 0},
+ {"= test", -1, 0, 0},
+ {"= test ", -1, 0, 0},
+ {"= test 1", -1, 0, 0},
+ {"= test 1 ", -1, 0, 0},
+ {"= test 1 2", -1, 0, 0},
+ {"= test 1 2 ", -1, 0, 0},
+ {"= test 1 2 3", -1, 0, 0},
+ {NULL, 0, 0, 0}
+ };
+
+ collie_test *test = node_info_tests;
+
+ if (virAsprintf(&poolxml, "%s/storagepoolxml2xmlin/pool-sheepdog.xml",
+ abs_srcdir) < 0)
+ goto cleanup;
+
+ if (virAsprintf(&volxml, "%s/storagevolxml2xmlin/vol-sheepdog.xml",
+ abs_srcdir) < 0)
+ goto cleanup;
+
+ while (test->output != NULL) {
+ ret = test_node_info_parser(*test, poolxml);
+ virtTestResult("node_info_parser", ret, NULL);
+ ++test;
+ if (ret < 0)
+ return EXIT_FAILURE;
+ }
+
+ test = vdi_list_tests;
+
+ while (test->output != NULL) {
+ ret = test_vdi_list_parser(*test, poolxml, volxml);
+ virtTestResult("vdi_list_parser", ret, NULL);
+ ++test;
+ if (ret < 0)
+ return EXIT_FAILURE;
+ }
+
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(poolxml);
+ VIR_FREE(volxml);
+ return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+
+VIRT_TEST_MAIN(mymain)
diff --git a/tests/storagepoolxml2xmlin/pool-sheepdog.xml b/tests/storagepoolxml2xmlin/pool-sheepdog.xml
new file mode 100644
index 0000000..1287047
--- /dev/null
+++ b/tests/storagepoolxml2xmlin/pool-sheepdog.xml
@@ -0,0 +1,8 @@
+<pool type='sheepdog'>
+ <name>sheepdog</name>
+ <uuid>65fcba04-5b13-bd93-cff3-52ce48e11ad7</uuid>
+ <source>
+ <host name='localhost' port='7000'/>
+ <name>sheepdog</name>
+ </source>
+</pool>
diff --git a/tests/storagepoolxml2xmlout/pool-sheepdog.xml b/tests/storagepoolxml2xmlout/pool-sheepdog.xml
new file mode 100644
index 0000000..000c068
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-sheepdog.xml
@@ -0,0 +1,11 @@
+<pool type='sheepdog'>
+ <name>sheepdog</name>
+ <uuid>65fcba04-5b13-bd93-cff3-52ce48e11ad7</uuid>
+ <capacity unit='bytes'>0</capacity>
+ <allocation unit='bytes'>0</allocation>
+ <available unit='bytes'>0</available>
+ <source>
+ <host name='localhost' port='7000'/>
+ <name>sheepdog</name>
+ </source>
+</pool>
diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c
index d73fc8a..8cac978 100644
--- a/tests/storagepoolxml2xmltest.c
+++ b/tests/storagepoolxml2xmltest.c
@@ -93,6 +93,7 @@ mymain(void)
DO_TEST("pool-mpath");
DO_TEST("pool-iscsi-multiiqn");
DO_TEST("pool-iscsi-vendor-product");
+ DO_TEST("pool-sheepdog");
return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/tests/storagevolxml2xmlin/vol-sheepdog.xml b/tests/storagevolxml2xmlin/vol-sheepdog.xml
new file mode 100644
index 0000000..49e221c
--- /dev/null
+++ b/tests/storagevolxml2xmlin/vol-sheepdog.xml
@@ -0,0 +1,10 @@
+<volume>
+ <name>test2</name>
+ <source>
+ </source>
+ <capacity unit='bytes'>1024</capacity>
+ <allocation unit='bytes'>0</allocation>
+ <target>
+ <path>sheepdog:test2</path>
+ </target>
+</volume>
diff --git a/tests/storagevolxml2xmlout/vol-sheepdog.xml b/tests/storagevolxml2xmlout/vol-sheepdog.xml
new file mode 100644
index 0000000..2f19af8
--- /dev/null
+++ b/tests/storagevolxml2xmlout/vol-sheepdog.xml
@@ -0,0 +1,17 @@
+<volume>
+ <name>test2</name>
+ <key>(null)</key>
+ <source>
+ </source>
+ <capacity unit='bytes'>1024</capacity>
+ <allocation unit='bytes'>0</allocation>
+ <target>
+ <path>sheepdog:test2</path>
+ <format type='unknown'/>
+ <permissions>
+ <mode>0600</mode>
+ <owner>4294967295</owner>
+ <group>4294967295</group>
+ </permissions>
+ </target>
+</volume>
diff --git a/tests/storagevolxml2xmltest.c b/tests/storagevolxml2xmltest.c
index 37c92cd..ee85988 100644
--- a/tests/storagevolxml2xmltest.c
+++ b/tests/storagevolxml2xmltest.c
@@ -112,6 +112,7 @@ mymain(void)
DO_TEST("pool-disk", "vol-partition");
DO_TEST("pool-logical", "vol-logical");
DO_TEST("pool-logical", "vol-logical-backing");
+ DO_TEST("pool-sheepdog", "vol-sheepdog");
return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/tools/virsh.c b/tools/virsh.c
index 2b4cb2c..dd0261c 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -20696,6 +20696,9 @@ vshShowVersion(vshControl *ctl ATTRIBUTE_UNUSED)
#ifdef WITH_STORAGE_RBD
vshPrint(ctl, " RBD");
#endif
+#ifdef WITH_STORAGE_SHEEPDOG
+ vshPrint(ctl, " Sheepdog");
+#endif
vshPrint(ctl, "\n");
vshPrint(ctl, "%s", _(" Miscellaneous:"));
--
1.7.9.4
2
3
For objects with a subtype 'type' attribute, when the _new_from_xml
function was called, the 'type' attribute was forcefully set to the
right value rather than checking that the passed-in value matches
the type of the subclass we are trying to instantiate. This commit
changes this, and returns NULL when the value of the 'type' attribute
of the passed-in XML document does not match the expected type.
---
libvirt-gconfig/libvirt-gconfig-domain-address-pci.c | 2 +-
libvirt-gconfig/libvirt-gconfig-domain-address-usb.c | 2 +-
libvirt-gconfig/libvirt-gconfig-domain-chardev-source-pty.c | 2 +-
libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.c | 2 +-
libvirt-gconfig/libvirt-gconfig-domain-controller-usb.c | 2 +-
libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.c | 4 +---
libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c | 4 +---
libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c | 4 +---
libvirt-gconfig/libvirt-gconfig-domain-interface-bridge.c | 4 +---
libvirt-gconfig/libvirt-gconfig-domain-interface-network.c | 4 +---
libvirt-gconfig/libvirt-gconfig-domain-interface-user.c | 4 +---
libvirt-gconfig/libvirt-gconfig-domain-timer-pit.c | 2 +-
libvirt-gconfig/libvirt-gconfig-domain-timer-rtc.c | 2 +-
13 files changed, 13 insertions(+), 25 deletions(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-address-pci.c b/libvirt-gconfig/libvirt-gconfig-domain-address-pci.c
index 48e3872..5199b8a 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-address-pci.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-address-pci.c
@@ -67,7 +67,7 @@ GVirConfigDomainAddressPci *gvir_config_domain_address_pci_new_from_xml(const gc
object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_ADDRESS_PCI,
"address", NULL, xml, error);
- gvir_config_object_set_attribute(object, "type", "pci", NULL);
+ g_return_val_if_fail(g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "pci") != 0, NULL);
return GVIR_CONFIG_DOMAIN_ADDRESS_PCI(object);
}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-address-usb.c b/libvirt-gconfig/libvirt-gconfig-domain-address-usb.c
index 3da5811..c1305c2 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-address-usb.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-address-usb.c
@@ -67,7 +67,7 @@ GVirConfigDomainAddressUsb *gvir_config_domain_address_usb_new_from_xml(const gc
object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_ADDRESS_USB,
"address", NULL, xml, error);
- gvir_config_object_set_attribute(object, "type", "usb", NULL);
+ g_return_val_if_fail(g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "usb") != 0, NULL);
return GVIR_CONFIG_DOMAIN_ADDRESS_USB(object);
}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-pty.c b/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-pty.c
index 201e123..097834a 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-pty.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-pty.c
@@ -75,7 +75,7 @@ GVirConfigDomainChardevSourcePty *gvir_config_domain_chardev_source_pty_new_from
*/
object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE_PTY,
"dummy", NULL, xml, error);
- gvir_config_object_set_attribute(object, "type", "pty", NULL);
+ g_return_val_if_fail(g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "pty") != 0, NULL);
return GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE_PTY(object);
}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.c b/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.c
index 22eabf5..bef17cb 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.c
@@ -75,6 +75,6 @@ GVirConfigDomainChardevSourceSpiceVmc *gvir_config_domain_chardev_source_spicevm
*/
object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE_SPICE_VMC,
"dummy", NULL, xml, error);
- gvir_config_object_set_attribute(object, "type", "spicevmc", NULL);
+ g_return_val_if_fail(g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "spicevmc") != 0, NULL);
return GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_VMC(object);
}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-controller-usb.c b/libvirt-gconfig/libvirt-gconfig-domain-controller-usb.c
index 1fd248c..0f8bca3 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-controller-usb.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-controller-usb.c
@@ -167,7 +167,7 @@ GVirConfigDomainControllerUsb *gvir_config_domain_controller_usb_new_from_xml(co
object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_CONTROLLER_USB,
"controller", NULL, xml, error);
- gvir_config_object_set_attribute(object, "type", "usb", NULL);
+ g_return_val_if_fail(g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "usb") != 0, NULL);
return GVIR_CONFIG_DOMAIN_CONTROLLER_USB(object);
}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.c
index 7871ae5..dd2b60c 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.c
@@ -68,9 +68,7 @@ gvir_config_domain_graphics_sdl_new_from_xml(const gchar *xml,
object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_SDL,
"graphics", NULL, xml, error);
- if (object == NULL)
- return NULL;
- gvir_config_object_set_attribute(object, "type", "sdl", NULL);
+ g_return_val_if_fail(g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "sdl") != 0, NULL);
return GVIR_CONFIG_DOMAIN_GRAPHICS_SDL(object);
}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c
index e60a778..e41abd2 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c
@@ -68,9 +68,7 @@ gvir_config_domain_graphics_spice_new_from_xml(const gchar *xml,
object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_SPICE,
"graphics", NULL, xml, error);
- if (object == NULL)
- return NULL;
- gvir_config_object_set_attribute(object, "type", "spice", NULL);
+ g_return_val_if_fail(g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "spice") != 0, NULL);
return GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE(object);
}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c
index d9d1303..aeed7c6 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c
@@ -68,9 +68,7 @@ gvir_config_domain_graphics_vnc_new_from_xml(const gchar *xml,
object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_VNC,
"graphics", NULL, xml, error);
- if (object == NULL)
- return NULL;
- gvir_config_object_set_attribute(object, "type", "vnc", NULL);
+ g_return_val_if_fail(g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "vnc") != 0, NULL);
return GVIR_CONFIG_DOMAIN_GRAPHICS_VNC(object);
}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface-bridge.c b/libvirt-gconfig/libvirt-gconfig-domain-interface-bridge.c
index ea5eafa..e7e43d4 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-interface-bridge.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface-bridge.c
@@ -70,9 +70,7 @@ GVirConfigDomainInterfaceBridge *gvir_config_domain_interface_bridge_new_from_xm
object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_BRIDGE,
"interface", NULL, xml, error);
- if (object == NULL)
- return NULL;
- gvir_config_object_set_attribute(object, "type", "bridge", NULL);
+ g_return_val_if_fail(g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "bridge") != 0, NULL);
return GVIR_CONFIG_DOMAIN_INTERFACE_BRIDGE(object);
}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface-network.c b/libvirt-gconfig/libvirt-gconfig-domain-interface-network.c
index 1a7bfad..7f19cc8 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-interface-network.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface-network.c
@@ -69,9 +69,7 @@ GVirConfigDomainInterfaceNetwork *gvir_config_domain_interface_network_new_from_
object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_NETWORK,
"interface", NULL, xml, error);
- if (object == NULL)
- return NULL;
- gvir_config_object_set_attribute(object, "type", "network", NULL);
+ g_return_val_if_fail(g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "network") != 0, NULL);
return GVIR_CONFIG_DOMAIN_INTERFACE_NETWORK(object);
}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface-user.c b/libvirt-gconfig/libvirt-gconfig-domain-interface-user.c
index a455a73..2d29abc 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-interface-user.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface-user.c
@@ -69,8 +69,6 @@ GVirConfigDomainInterfaceUser *gvir_config_domain_interface_user_new_from_xml(co
object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_USER,
"interface", NULL, xml, error);
- if (object == NULL)
- return NULL;
- gvir_config_object_set_attribute(object, "type", "user", NULL);
+ g_return_val_if_fail(g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "user") != 0, NULL);
return GVIR_CONFIG_DOMAIN_INTERFACE_USER(object);
}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-timer-pit.c b/libvirt-gconfig/libvirt-gconfig-domain-timer-pit.c
index d75cd30..671a9dc 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-timer-pit.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-timer-pit.c
@@ -67,6 +67,6 @@ GVirConfigDomainTimerPit *gvir_config_domain_timer_pit_new_from_xml(const gchar
object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_TIMER_PIT,
"timer", NULL, xml, error);
- gvir_config_object_set_attribute(object, "name", "pit", NULL);
+ g_return_val_if_fail(g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "pit") != 0, NULL);
return GVIR_CONFIG_DOMAIN_TIMER_PIT(object);
}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-timer-rtc.c b/libvirt-gconfig/libvirt-gconfig-domain-timer-rtc.c
index b99c1e3..4b36dcd 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-timer-rtc.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-timer-rtc.c
@@ -67,6 +67,6 @@ GVirConfigDomainTimerRtc *gvir_config_domain_timer_rtc_new_from_xml(const gchar
object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_TIMER_RTC,
"timer", NULL, xml, error);
- gvir_config_object_set_attribute(object, "name", "rtc", NULL);
+ g_return_val_if_fail(g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "rtc") != 0, NULL);
return GVIR_CONFIG_DOMAIN_TIMER_RTC(object);
}
--
1.7.10.4
1
1