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
- 25 participants
- 40185 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
Hi,
I'm using the API virDomainMemoryStats to fetch memory stats for a domain/guest on Fedora 16/RHEL 6.3 . I don't get these counters filled up
VIR_DOMAIN_MEMORY_STAT_UNUSED, VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON,VIR_DOMAIN_MEMORY_STAT_AVAILABLE , VIR_DOMAIN_MEMORY_STAT_MAJOR_FAULT and VIR_DOMAIN_MEMORY_STAT_MINOR_FAULT. The version of libvirt 0.9.11 on Fedora 16 . How to get all the counters filled up ? Should I take a specific version of qemu or should I do some config settings so that these values are filled up ?
P.S. Please copy me in reply
Regards,
Navin Parakkal
HP Software
3
3
[libvirt] [PATCH] storage: netfs and iscsi need option srcSpec for resource discovery
by Guannan Ren 18 Jul '12
by Guannan Ren 18 Jul '12
18 Jul '12
The option 'srcSpec' to virsh command find-storage-pool-sources
is optional for logical type of storage pool, but mandatory for
netfs and iscsi type.
When missing the option for netfs and iscsi, libvirt reports XML
parsing error due to null string option srcSpec.
error: Failed to find any netfs pool sources
error: (storage_source_specification):1: Document is empty
(null)
This patch adds a check for it, error info changed to:
error: Failed to find any netfs pool sources
error: internal error pool type 'netfs' need option \
--srcSpec for source discovery
---
src/storage/storage_driver.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index fbc630d..e5f3e1b 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -458,6 +458,14 @@ storageFindPoolSources(virConnectPtr conn,
goto cleanup;
}
+ if ((*srcSpec == '\0') && (backend_type == VIR_STORAGE_POOL_ISCSI ||
+ backend_type == VIR_STORAGE_POOL_NETFS)) {
+ virStorageReportError(VIR_ERR_INTERNAL_ERROR,
+ _("pool type '%s' need option --srcSpec "
+ "for source discovery"), type);
+ goto cleanup;
+ }
+
ret = backend->findPoolSources(conn, srcSpec, flags);
cleanup:
--
1.7.7.5
2
2
[libvirt] [glib PATCH V2] Add bindings for virStorageDownload() and virStorageUpload()
by Jovanka Gulicoska 18 Jul '12
by Jovanka Gulicoska 18 Jul '12
18 Jul '12
---
libvirt-gobject/libvirt-gobject-storage-vol.c | 85 +++++++++++++++++++++++++
libvirt-gobject/libvirt-gobject-storage-vol.h | 14 ++++
libvirt-gobject/libvirt-gobject.h | 1 +
libvirt-gobject/libvirt-gobject.sym | 2 +
4 files changed, 102 insertions(+)
diff --git a/libvirt-gobject/libvirt-gobject-storage-vol.c b/libvirt-gobject/libvirt-gobject-storage-vol.c
index 6f60fcd..462a99e 100644
--- a/libvirt-gobject/libvirt-gobject-storage-vol.c
+++ b/libvirt-gobject/libvirt-gobject-storage-vol.c
@@ -349,3 +349,88 @@ gboolean gvir_storage_vol_resize(GVirStorageVol *vol,
return TRUE;
}
+
+/**
+ * gvir_storage_vol_download:
+ * @vol: the storage volume to download from
+ * @stream: stream to use as output
+ * @offset: position in @vol to start reading from
+ * @length: limit on amount of data to download
+ * @flags: extra flags, not used yet, pass 0
+ *
+ * Returns: #TRUE of success, #FALSE otherwise
+ */
+gboolean gvir_storage_vol_download(GVirStorageVol *vol,
+ GVirStream *stream,
+ unsigned long long offset,
+ unsigned long long length,
+ guint flags,
+ GError **err)
+{
+ virStreamPtr st = NULL;
+ gboolean ret = FALSE;
+
+ g_object_get(stream, "handle", &st, NULL);
+
+ g_return_val_if_fail(GVIR_IS_STORAGE_VOL(vol), FALSE);
+ g_return_val_if_fail(GVIR_IS_STREAM(stream), FALSE);
+ g_return_val_if_fail(err == NULL || *err == NULL, FALSE);
+
+ if (virStorageVolDownload(vol->priv->handle, st, offset, length, 0) < 0) {
+ gvir_set_error_literal(err,
+ GVIR_STORAGE_VOL_ERROR,
+ 0,
+ "Unable to downlaod volume storage");
+
+ goto cleanup;
+ }
+
+ ret = TRUE;
+cleanup:
+ if (st != NULL)
+ virStreamFree(st);
+ return ret;
+}
+
+/**
+ * gvir_storage_vol_upload:
+ * @vol: the storage volume to upload
+ * @stream: stream to use as input
+ * @offset: position in @vol to start to write to
+ * @length: limit on amount of data to upload
+ * @flags: the flags, not set yet, pass 0
+ *
+ * Returns: #TRUE of success, #FALSE otherwise
+ */
+gboolean gvir_storage_vol_upload(GVirStorageVol *vol,
+ GVirStream *stream,
+ unsigned long long offset,
+ unsigned long long length,
+ guint flags,
+ GError **err)
+{
+ virStreamPtr st = NULL;
+ gboolean ret = FALSE;
+
+ g_object_get(stream, "handle", &st, NULL);
+
+ g_return_val_if_fail(GVIR_IS_STORAGE_VOL(vol), FALSE);
+ g_return_val_if_fail(GVIR_IS_STREAM(stream), FALSE);
+ g_return_val_if_fail(err == NULL || *err == NULL, FALSE);
+
+ if (virStorageVolUpload(vol->priv->handle, st, offset, length, 0) < 0) {
+ gvir_set_error_literal(err,
+ GVIR_STORAGE_VOL_ERROR,
+ 0,
+ "Unable to upload to stream");
+
+ goto cleanup;
+ }
+
+ ret = TRUE;
+cleanup:
+ if (st != NULL)
+ virStreamFree(st);
+ return ret;
+}
+
diff --git a/libvirt-gobject/libvirt-gobject-storage-vol.h b/libvirt-gobject/libvirt-gobject-storage-vol.h
index b425f0a..e156792 100644
--- a/libvirt-gobject/libvirt-gobject-storage-vol.h
+++ b/libvirt-gobject/libvirt-gobject-storage-vol.h
@@ -110,6 +110,20 @@ gboolean gvir_storage_vol_resize(GVirStorageVol *vol,
guint flags,
GError **err);
+gboolean gvir_storage_vol_download(GVirStorageVol *vol,
+ GVirStream *stream,
+ unsigned long long offset,
+ unsigned long long length,
+ guint flags,
+ GError **err);
+
+gboolean gvir_storage_vol_upload(GVirStorageVol *vol,
+ GVirStream *stream,
+ unsigned long long offset,
+ unsigned long long length,
+ guint flags,
+ GError **err);
+
G_END_DECLS
#endif /* __LIBVIRT_GOBJECT_STORAGE_VOL_H__ */
diff --git a/libvirt-gobject/libvirt-gobject.h b/libvirt-gobject/libvirt-gobject.h
index f52cc00..b1158f7 100644
--- a/libvirt-gobject/libvirt-gobject.h
+++ b/libvirt-gobject/libvirt-gobject.h
@@ -44,5 +44,6 @@
#include <libvirt-gobject/libvirt-gobject-storage-pool.h>
#include <libvirt-gobject/libvirt-gobject-connection.h>
#include <libvirt-gobject/libvirt-gobject-manager.h>
+#include <libvirt-gobject/libvirt-gobject-stream.h>
#endif /* __LIBVIRT_GOBJECT_H__ */
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index db32c7f..478881b 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -143,6 +143,8 @@ LIBVIRT_GOBJECT_0.0.8 {
gvir_storage_vol_get_info;
gvir_storage_vol_delete;
gvir_storage_vol_resize;
+ gvir_storage_vol_download;
+ gvir_storage_vol_upload;
gvir_connection_handle_get_type;
--
1.7.10.4
4
3
When building with --disable-debug, VIR_DEBUG expands to a nop.
But parameters to VIR_DEBUG can be variables that are passed only
to VIR_DEBUG. In the case the building system complains about unused
variables.
---
src/util/logging.h | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/util/logging.h b/src/util/logging.h
index 70318d0..2e70af4 100644
--- a/src/util/logging.h
+++ b/src/util/logging.h
@@ -34,8 +34,21 @@
# define VIR_DEBUG_INT(category, f, l, ...) \
virLogMessage(category, VIR_LOG_DEBUG, f, l, 0, __VA_ARGS__)
# else
+/**
+ * virLogEatParam:
+ *
+ * Do nothing but eat parameters.
+ */
+static inline void virLogEatParam(const char *category,
+ const char *funcname,
+ long long linenr, ...)
+{
+ category = category;
+ funcname = funcname;
+ linenr = linenr;
+}
# define VIR_DEBUG_INT(category, f, l, ...) \
- do { } while (0)
+ virLogEatParam(category, f, l, __VA_ARGS__)
# endif /* !ENABLE_DEBUG */
# define VIR_INFO_INT(category, f, l, ...) \
--
1.7.10.2
5
4
Remote driver needs to make sure the driver lock is released before
entering client IO loop as that may block indefinitely in poll(). As a
direct consequence of not following this in stream APIs, tunneled
migration to a destination host which becomes non-responding may block
qemu driver. Luckily, if keepalive is turned for p2p migrations, both
remote and qemu drivers will get automagically unblocked after keepalive
timeout.
---
src/remote/remote_driver.c | 40 ++++++++++++++++++++++++++++------------
1 file changed, 28 insertions(+), 12 deletions(-)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 3314f80..acae5d0 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -3976,12 +3976,14 @@ remoteStreamSend(virStreamPtr st,
VIR_DEBUG("st=%p data=%p nbytes=%zu", st, data, nbytes);
struct private_data *priv = st->conn->privateData;
virNetClientStreamPtr privst = st->privateData;
- int rv = -1;
-
- remoteDriverLock(priv);
+ int rv;
if (virNetClientStreamRaiseError(privst))
- goto cleanup;
+ return -1;
+
+ remoteDriverLock(priv);
+ priv->localUses++;
+ remoteDriverUnlock(priv);
rv = virNetClientStreamSendPacket(privst,
priv->client,
@@ -3989,9 +3991,9 @@ remoteStreamSend(virStreamPtr st,
data,
nbytes);
-cleanup:
+ remoteDriverLock(priv);
+ priv->localUses--;
remoteDriverUnlock(priv);
-
return rv;
}
@@ -4004,12 +4006,14 @@ remoteStreamRecv(virStreamPtr st,
VIR_DEBUG("st=%p data=%p nbytes=%zu", st, data, nbytes);
struct private_data *priv = st->conn->privateData;
virNetClientStreamPtr privst = st->privateData;
- int rv = -1;
-
- remoteDriverLock(priv);
+ int rv;
if (virNetClientStreamRaiseError(privst))
- goto cleanup;
+ return -1;
+
+ remoteDriverLock(priv);
+ priv->localUses++;
+ remoteDriverUnlock(priv);
rv = virNetClientStreamRecvPacket(privst,
priv->client,
@@ -4019,9 +4023,9 @@ remoteStreamRecv(virStreamPtr st,
VIR_DEBUG("Done %d", rv);
-cleanup:
+ remoteDriverLock(priv);
+ priv->localUses--;
remoteDriverUnlock(priv);
-
return rv;
}
@@ -4138,12 +4142,18 @@ remoteStreamFinish(virStreamPtr st)
if (virNetClientStreamRaiseError(privst))
goto cleanup;
+ priv->localUses++;
+ remoteDriverUnlock(priv);
+
ret = virNetClientStreamSendPacket(privst,
priv->client,
VIR_NET_OK,
NULL,
0);
+ remoteDriverLock(priv);
+ priv->localUses--;
+
cleanup:
virNetClientRemoveStream(priv->client, privst);
virNetClientStreamFree(privst);
@@ -4167,12 +4177,18 @@ remoteStreamAbort(virStreamPtr st)
if (virNetClientStreamRaiseError(privst))
goto cleanup;
+ priv->localUses++;
+ remoteDriverUnlock(priv);
+
ret = virNetClientStreamSendPacket(privst,
priv->client,
VIR_NET_ERROR,
NULL,
0);
+ remoteDriverLock(priv);
+ priv->localUses--;
+
cleanup:
virNetClientRemoveStream(priv->client, privst);
virNetClientStreamFree(privst);
--
1.7.11.1
2
2
Re: [libvirt] How to get the real device in guest os after attached a disk?
by Stefan Hajnoczi 18 Jul '12
by Stefan Hajnoczi 18 Jul '12
18 Jul '12
On Tue, Jul 17, 2012 at 4:40 AM, Wangpan <hzwangpan(a)corp.netease.com> wrote:
> I have a question as the subject above, the reason I want to know this is that, if I attach some disks on the guest,
> for example, I specified /dev/vdc&/dev/vdd(target device) at the cmd line by using 'virsh attach-disk', but they may be /dev/vdb&/dev/vdc in the guest os,
> so if the guest user want to detach the /dev/vdb(guest device), he\she will be confused with the two target devices /dev/vdb&/dev/vdc,
> because he\she doesn't know the corresponding relation of the guest device and target device,
> he\she may detach an error device /dev/vdd(target device) which corresponding to /dev/vdc(guest device).
>
> Could anyone give me some idea?
You can use the virtio-blk serial or file system/volume labels to
distinguish them.
For libvirt disk <serial> information, see the Domain XML documentation:
http://libvirt.org/formatdomain.html#elementsDisks
Stefan
2
2
---
Can't we just get rid of this horrific and mostly unmaintained xenapi code
completely? :-)
src/xenapi/xenapi_driver.c | 3 ++-
src/xenapi/xenapi_utils.c | 36 ++++++++++++++----------------------
2 files changed, 16 insertions(+), 23 deletions(-)
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 298ab21..a91f497 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -1512,7 +1512,8 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
}
xen_vif_get_record(session, &vif_rec, vif);
if (vif_rec != NULL) {
- if (virMacAddrParse((const char *)vif_rec->mac,defPtr->nets[i]->mac) < 0)
+ if (virMacAddrParse((const char *)vif_rec->mac,
+ &defPtr->nets[i]->mac) < 0)
xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
_("Unable to parse given mac address"));
xen_vif_record_free(vif_rec);
diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c
index e5a9cc5..c8b12de 100644
--- a/src/xenapi/xenapi_utils.c
+++ b/src/xenapi/xenapi_utils.c
@@ -453,7 +453,6 @@ createVMRecordFromXml (virConnectPtr conn, virDomainDefPtr def,
char uuidStr[VIR_UUID_STRING_BUFLEN];
xen_string_string_map *strings = NULL;
int device_number = 0;
- char *bridge = NULL, *mac = NULL;
int i;
*record = xen_vm_record_alloc();
@@ -542,28 +541,21 @@ createVMRecordFromXml (virConnectPtr conn, virDomainDefPtr def,
}
for (i = 0; i < def->nnets; i++) {
- if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
- if (def->nets[i]->data.bridge.brname)
- if (!(bridge = strdup(def->nets[i]->data.bridge.brname)))
- goto error_cleanup;
- if (def->nets[i]->mac) {
- char macStr[VIR_MAC_STRING_BUFLEN];
- virMacAddrFormat(def->nets[i]->mac, macStr);
- if (!(mac = strdup(macStr))) {
- VIR_FREE(bridge);
- goto error_cleanup;
- }
- }
- if (mac != NULL && bridge != NULL) {
- if (createVifNetwork(conn, *vm, device_number, bridge,
- mac) < 0) {
- VIR_FREE(bridge);
- goto error_cleanup;
- }
- VIR_FREE(bridge);
- device_number++;
+ if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_BRIDGE &&
+ def->nets[i]->data.bridge.brname) {
+ char *mac;
+
+ if (VIR_ALLOC_N(mac, VIR_MAC_STRING_BUFLEN) < 0)
+ goto error_cleanup;
+ virMacAddrFormat(&def->nets[i]->mac, mac);
+
+ if (createVifNetwork(conn, *vm, device_number,
+ def->nets[i]->data.bridge.brname,
+ mac) < 0) {
+ VIR_FREE(mac);
+ goto error_cleanup;
}
- VIR_FREE(bridge);
+ device_number++;
}
}
return 0;
--
1.7.11.1
2
2
I'm curious to know how you are providing IPs for your Windows VMs
when connected via a bridge. Since broadcasts from the VMs are going
out the bridged interface, I'm thinking about implementing ebtables to
block dhcp broadcasts from going in/out the interface so that dnsmasq
would only respond to dhcp requests from the local guest VMs. Before
I venture down this path, I thought I might ask if there's an easier
way to do this with libvirt.
Thanks for any help.
2
1
[libvirt] [PATCH] nwfilter: Convert to virMacAddrPtr not virMacAddrPtr*
by Michal Privoznik 17 Jul '12
by Michal Privoznik 17 Jul '12
17 Jul '12
My previous patch wasn't complete as it converted from
(unsigned char *) to (virMacAddrPtr *). It should be
(virMacAddrPtr) only.
---
Again, pushed under build breaker.
src/nwfilter/nwfilter_dhcpsnoop.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c
index 312fada..b38e780 100644
--- a/src/nwfilter/nwfilter_dhcpsnoop.c
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -2200,7 +2200,7 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver ATTRIBUTE_UNUSED,
const char *linkdev ATTRIBUTE_UNUSED,
enum virDomainNetType nettype ATTRIBUTE_UNUSED,
const unsigned char *vmuuid ATTRIBUTE_UNUSED,
- const virMacAddrPtr *macaddr ATTRIBUTE_UNUSED,
+ const virMacAddrPtr macaddr ATTRIBUTE_UNUSED,
const char *filtername ATTRIBUTE_UNUSED,
virNWFilterHashTablePtr filterparams ATTRIBUTE_UNUSED,
virNWFilterDriverStatePtr driver ATTRIBUTE_UNUSED)
--
1.7.8.6
1
0
[libvirt] [PATCH 0/4] qemu: configurable port boundaries for remote displays
by Martin Kletzander 17 Jul '12
by Martin Kletzander 17 Jul '12
17 Jul '12
This series introduces a possibility to change default minimal and
maximal port numbers that are used to specify a remote display port
for both VNC and SPICE.
Because the code was a bit messy, PATCH 1/4 cleans up few things
needed to make a clean run of PATCH 2/4, that does the main change in
the code.
I also noticed two things that could be changed and it made sense for
me to do that, but these are nowhere near any importance, so feel free
to reject them if your heart feels that way.
PATCH 3/4 rewords three messages and applying it would mean that they are not translated. Even though I think it makes more sense this way, I'm not a good English speaker, so that's more like an RFC.
PATCH 4/4 makes more flexible port searching available, but is used on one place and because there are so many ports, it won't be that used, I guess.
P.S.: this is basically v2 for
https://www.redhat.com/archives/libvir-list/2012-May/msg01081.html but
it changed a lot and the name is also different, so I didn't want to
create any confision.
Martin Kletzander (4):
qemu: Unify port-wise SPICE and VNC behavior
qemu: configurable remote display port boundaries
qemu: modify 3 error messages
qemu: allow searching for all open ports
src/conf/domain_conf.c | 2 +-
src/qemu/libvirtd_qemu.aug | 4 ++
src/qemu/qemu.conf | 14 ++++++
src/qemu/qemu_command.h | 11 ++++-
src/qemu/qemu_conf.c | 40 +++++++++++++++++-
src/qemu/qemu_conf.h | 4 +-
src/qemu/qemu_driver.c | 19 ++++-----
src/qemu/qemu_process.c | 81 +++++++++++++++++++++---------------
src/qemu/test_libvirtd_qemu.aug.in | 2 +
9 files changed, 128 insertions(+), 49 deletions(-)
--
1.7.8.6
1
6
17 Jul '12
The previous commit (387117ad92) was incomplete leaving those
who does not use libpcap with uncompilable sources beacuse
of incomplete conversion of virNWFilterDHCPSnoopReq function.
---
Pushing under build breaker and trivial rules.
src/nwfilter/nwfilter_dhcpsnoop.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c
index d712b15..312fada 100644
--- a/src/nwfilter/nwfilter_dhcpsnoop.c
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -2200,7 +2200,7 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver ATTRIBUTE_UNUSED,
const char *linkdev ATTRIBUTE_UNUSED,
enum virDomainNetType nettype ATTRIBUTE_UNUSED,
const unsigned char *vmuuid ATTRIBUTE_UNUSED,
- const unsigned char *macaddr ATTRIBUTE_UNUSED,
+ const virMacAddrPtr *macaddr ATTRIBUTE_UNUSED,
const char *filtername ATTRIBUTE_UNUSED,
virNWFilterHashTablePtr filterparams ATTRIBUTE_UNUSED,
virNWFilterDriverStatePtr driver ATTRIBUTE_UNUSED)
--
1.7.8.6
1
0
See https://www.redhat.com/archives/libvir-list/2012-July/msg00493.html
Basically building against librbd doesn't seem to actually require -lcrypto.
Also report the rbd linker flags in configure output
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
configure.ac | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index d45f4f1..ae814cb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1999,7 +1999,7 @@ if test "$with_storage_rbd" = "yes" || test "$with_storage_rbd" = "check"; then
if test "$LIBRBD_FOUND" = "yes"; then
with_storage_rbd=yes
- LIBRBD_LIBS="-lrbd -lrados -lcrypto"
+ LIBRBD_LIBS="-lrbd -lrados"
AC_DEFINE_UNQUOTED([WITH_STORAGE_RBD], [1],
[whether RBD backend for storage driver is enabled])
else
@@ -2962,6 +2962,12 @@ AC_MSG_NOTICE([ xdr: $XDR_CFLAGS])
else
AC_MSG_NOTICE([ xdr: no])
fi
+if test "$with_storage_rbd" = "yes" ; then
+AC_MSG_NOTICE([ rbd: $LIBRBD_LIBS])
+else
+AC_MSG_NOTICE([ rbd: no])
+fi
+
AC_MSG_NOTICE([])
AC_MSG_NOTICE([Test suite])
AC_MSG_NOTICE([])
--
1.7.10.4
2
2
17 Jul '12
Introduce new members in the virMacAddr 'class'
- virMacAddrSet: set virMacAddr from a virMacAddr
- virMacAddrSetRaw: setting virMacAddr from raw 6 byte MAC address buffer
- virMacAddrGetRaw: writing virMacAddr into raw 6 byte MAC address buffer
- virMacAddrCmp: comparing two virMacAddr
- virMacAddrCmpRaw: comparing a virMacAddr with a raw 6 byte MAC address buffer
then replace raw MAC addresses by replacing
- 'unsigned char *' with virMacAddrPtr
- 'unsigned char ... [VIR_MAC_BUFLEN]' with virMacAddr
and introduce usage of above functions where necessary.
---
src/conf/capabilities.c | 4 -
src/conf/capabilities.h | 4 -
src/conf/domain_audit.c | 6 -
src/conf/domain_conf.c | 32 ++++-----
src/conf/domain_conf.h | 6 -
src/conf/network_conf.c | 14 ++--
src/conf/network_conf.h | 2
src/conf/nwfilter_conf.c | 17 +---
src/conf/nwfilter_conf.h | 14 +---
src/conf/nwfilter_params.h | 1
src/libvirt_private.syms | 5 +
src/libxl/libxl_conf.c | 2
src/lxc/lxc_driver.c | 6 -
src/network/bridge_driver.c | 2
src/nwfilter/nwfilter_dhcpsnoop.c | 16 ++--
src/nwfilter/nwfilter_dhcpsnoop.h | 2
src/nwfilter/nwfilter_ebiptables_driver.c | 6 -
src/nwfilter/nwfilter_gentech_driver.c | 8 +-
src/nwfilter/nwfilter_gentech_driver.h | 2
src/nwfilter/nwfilter_learnipaddr.c | 29 +++-----
src/nwfilter/nwfilter_learnipaddr.h | 4 -
src/openvz/openvz_conf.c | 2
src/openvz/openvz_driver.c | 8 +-
src/qemu/qemu_bridge_filter.c | 4 -
src/qemu/qemu_bridge_filter.h | 4 -
src/qemu/qemu_command.c | 22 +++---
src/qemu/qemu_driver.c | 16 ++--
src/qemu/qemu_hostdev.c | 8 +-
src/qemu/qemu_hotplug.c | 14 ++--
src/qemu/qemu_migration.c | 6 -
src/qemu/qemu_process.c | 4 -
src/uml/uml_conf.c | 6 -
src/util/ebtables.c | 16 ++--
src/util/ebtables.h | 6 +
src/util/virmacaddr.c | 104 +++++++++++++++++++++++++-----
src/util/virmacaddr.h | 25 +++++--
src/util/virnetdev.c | 61 ++++++++---------
src/util/virnetdev.h | 11 +--
src/util/virnetdevmacvlan.c | 38 +++++-----
src/util/virnetdevmacvlan.h | 11 +--
src/util/virnetdevopenvswitch.c | 2
src/util/virnetdevopenvswitch.h | 2
src/util/virnetdevtap.c | 19 ++---
src/util/virnetdevtap.h | 2
src/util/virnetdevvportprofile.c | 18 ++---
src/util/virnetdevvportprofile.h | 5 -
src/util/virnetlink.c | 15 ++--
src/util/virnetlink.h | 7 +-
src/vbox/vbox_tmpl.c | 16 ++--
src/vmx/vmx.c | 10 +-
src/xen/xend_internal.c | 6 -
src/xen/xm_internal.c | 4 -
src/xenxs/xen_sxpr.c | 6 -
src/xenxs/xen_xm.c | 8 +-
tools/virsh.c | 8 +-
55 files changed, 377 insertions(+), 299 deletions(-)
Index: libvirt-acl/src/conf/domain_conf.h
===================================================================
--- libvirt-acl.orig/src/conf/domain_conf.h
+++ libvirt-acl/src/conf/domain_conf.h
@@ -785,7 +785,7 @@ struct _virDomainActualNetDef {
/* Stores the virtual network interface configuration */
struct _virDomainNetDef {
enum virDomainNetType type;
- unsigned char mac[VIR_MAC_BUFLEN];
+ virMacAddr mac;
char *model;
union {
struct {
@@ -1998,12 +1998,12 @@ virDomainDiskRemove(virDomainDefPtr def,
virDomainDiskDefPtr
virDomainDiskRemoveByName(virDomainDefPtr def, const char *name);
-int virDomainNetIndexByMac(virDomainDefPtr def, const unsigned char *mac);
+int virDomainNetIndexByMac(virDomainDefPtr def, const virMacAddrPtr mac);
int virDomainNetInsert(virDomainDefPtr def, virDomainNetDefPtr net);
virDomainNetDefPtr
virDomainNetRemove(virDomainDefPtr def, size_t i);
virDomainNetDefPtr
-virDomainNetRemoveByMac(virDomainDefPtr def, const unsigned char *mac);
+virDomainNetRemoveByMac(virDomainDefPtr def, const virMacAddrPtr mac);
int virDomainHostdevInsert(virDomainDefPtr def, virDomainHostdevDefPtr hostdev);
virDomainHostdevDefPtr
Index: libvirt-acl/src/util/virmacaddr.c
===================================================================
--- libvirt-acl.orig/src/util/virmacaddr.c
+++ libvirt-acl/src/util/virmacaddr.c
@@ -62,6 +62,76 @@ virMacAddrCompare(const char *p, const c
}
/**
+ * virMacAddrCmp:
+ * @mac1: pointer to 1st MAC address
+ * @mac2: pointer to 2nd MAC address
+ *
+ * Return 0 if MAC addresses are equal,
+ * < 0 if mac1 < mac2,
+ * > 0 if mac1 > mac2
+ */
+int
+virMacAddrCmp(const virMacAddrPtr mac1, const virMacAddrPtr mac2)
+{
+ return memcmp(mac1->addr, mac2->addr, VIR_MAC_BUFLEN);
+}
+
+/**
+ * virMacAddrCmpRaw:
+ * @mac1: pointer to 1st MAC address
+ * @mac2: pointer to 2nd MAC address in plain buffer
+ *
+ * Return 0 if MAC addresses are equal,
+ * < 0 if mac1 < mac2,
+ * > 0 if mac1 > mac2
+ */
+int
+virMacAddrCmpRaw(const virMacAddrPtr mac1,
+ const unsigned char mac2[VIR_MAC_BUFLEN])
+{
+ return memcmp(mac1->addr, mac2, VIR_MAC_BUFLEN);
+}
+
+/**
+ * virMacAddrSet
+ * @dst: pointer to destination
+ * @src: pointer to source
+ *
+ * Copy src to dst
+ */
+void
+virMacAddrSet(virMacAddrPtr dst, const virMacAddrPtr src)
+{
+ memcpy(dst, src, sizeof(*src));
+}
+
+/**
+ * virMacAddrSetRaw
+ * @dst: pointer to destination to hold MAC address
+ * @src: raw MAC address data
+ *
+ * Set the MAC address to the given value
+ */
+void
+virMacAddrSetRaw(virMacAddrPtr dst, const unsigned char src[VIR_MAC_BUFLEN])
+{
+ memcpy(dst->addr, src, VIR_MAC_BUFLEN);
+}
+
+/**
+ * virMacAddrGetRaw
+ * @src: pointer to MAC address
+ * @dst: pointer to raw memory to write MAC address into
+ *
+ * Copies the MAC address into raw memory
+ */
+void
+virMacAddrGetRaw(virMacAddrPtr src, unsigned char dst[VIR_MAC_BUFLEN])
+{
+ memcpy(dst, src->addr, VIR_MAC_BUFLEN);
+}
+
+/**
* virMacAddrParse:
* @str: string representation of MAC address, e.g., "0:1E:FC:E:3a:CB"
* @addr: 6-byte MAC address
@@ -71,7 +141,7 @@ virMacAddrCompare(const char *p, const c
* Return 0 upon success, or -1 in case of error.
*/
int
-virMacAddrParse(const char* str, unsigned char *addr)
+virMacAddrParse(const char* str, virMacAddrPtr addr)
{
int i;
@@ -93,7 +163,7 @@ virMacAddrParse(const char* str, unsigne
(0xFF < result))
break;
- addr[i] = (unsigned char) result;
+ addr->addr[i] = (unsigned char) result;
if ((i == 5) && (*end_ptr == '\0'))
return 0;
@@ -106,36 +176,36 @@ virMacAddrParse(const char* str, unsigne
return -1;
}
-void virMacAddrFormat(const unsigned char *addr,
+void virMacAddrFormat(const virMacAddrPtr addr,
char *str)
{
snprintf(str, VIR_MAC_STRING_BUFLEN,
"%02X:%02X:%02X:%02X:%02X:%02X",
- addr[0], addr[1], addr[2],
- addr[3], addr[4], addr[5]);
+ addr->addr[0], addr->addr[1], addr->addr[2],
+ addr->addr[3], addr->addr[4], addr->addr[5]);
str[VIR_MAC_STRING_BUFLEN-1] = '\0';
}
-void virMacAddrGenerate(const unsigned char *prefix,
- unsigned char *addr)
+void virMacAddrGenerate(const unsigned char prefix[VIR_MAC_PREFIX_BUFLEN],
+ virMacAddrPtr addr)
{
- addr[0] = prefix[0];
- addr[1] = prefix[1];
- addr[2] = prefix[2];
- addr[3] = virRandomBits(8);
- addr[4] = virRandomBits(8);
- addr[5] = virRandomBits(8);
+ addr->addr[0] = prefix[0];
+ addr->addr[1] = prefix[1];
+ addr->addr[2] = prefix[2];
+ addr->addr[3] = virRandomBits(8);
+ addr->addr[4] = virRandomBits(8);
+ addr->addr[5] = virRandomBits(8);
}
/* The low order bit of the first byte is the "multicast" bit. */
bool
-virMacAddrIsMulticast(const unsigned char *addr)
+virMacAddrIsMulticast(const virMacAddrPtr mac)
{
- return !!(addr[0] & 1);
+ return !!(mac->addr[0] & 1);
}
bool
-virMacAddrIsUnicast(const unsigned char *addr)
+virMacAddrIsUnicast(const virMacAddrPtr mac)
{
- return !(addr[0] & 1);
+ return !(mac->addr[0] & 1);
}
Index: libvirt-acl/src/util/virmacaddr.h
===================================================================
--- libvirt-acl.orig/src/util/virmacaddr.h
+++ libvirt-acl/src/util/virmacaddr.h
@@ -30,15 +30,26 @@
# define VIR_MAC_PREFIX_BUFLEN 3
# define VIR_MAC_STRING_BUFLEN (VIR_MAC_BUFLEN * 3)
-typedef unsigned char virMacAddr[VIR_MAC_BUFLEN];
+typedef struct _virMacAddr virMacAddr;
+typedef virMacAddr *virMacAddrPtr;
+
+struct _virMacAddr {
+ unsigned char addr[VIR_MAC_BUFLEN];
+};
int virMacAddrCompare(const char *mac1, const char *mac2);
-void virMacAddrFormat(const unsigned char *addr,
+int virMacAddrCmp(const virMacAddrPtr mac1, const virMacAddrPtr mac2);
+int virMacAddrCmpRaw(const virMacAddrPtr mac1,
+ const unsigned char s[VIR_MAC_BUFLEN]);
+void virMacAddrSet(virMacAddrPtr dst, const virMacAddrPtr src);
+void virMacAddrSetRaw(virMacAddrPtr dst, const unsigned char s[VIR_MAC_BUFLEN]);
+void virMacAddrGetRaw(virMacAddrPtr src, unsigned char dst[VIR_MAC_BUFLEN]);
+void virMacAddrFormat(const virMacAddrPtr addr,
char *str);
-void virMacAddrGenerate(const unsigned char *prefix,
- unsigned char *addr);
+void virMacAddrGenerate(const unsigned char prefix[VIR_MAC_PREFIX_BUFLEN],
+ virMacAddrPtr addr);
int virMacAddrParse(const char* str,
- unsigned char *addr) ATTRIBUTE_RETURN_CHECK;
-bool virMacAddrIsUnicast(const unsigned char *addr);
-bool virMacAddrIsMulticast(const unsigned char *addr);
+ virMacAddrPtr addr) ATTRIBUTE_RETURN_CHECK;
+bool virMacAddrIsUnicast(const virMacAddrPtr addr);
+bool virMacAddrIsMulticast(const virMacAddrPtr addr);
#endif /* __VIR_MACADDR_H__ */
Index: libvirt-acl/src/util/virnetdev.c
===================================================================
--- libvirt-acl.orig/src/util/virnetdev.c
+++ libvirt-acl/src/util/virnetdev.c
@@ -137,7 +137,7 @@ int virNetDevExists(const char *ifname)
/**
* virNetDevSetMAC:
* @ifname: interface name to set MTU for
- * @macaddr: MAC address (VIR_MAC_BUFLEN in size)
+ * @macaddr: MAC address
*
* This function sets the @macaddr for a given interface @ifname. This
* gets rid of the kernel's automatically assigned random MAC.
@@ -145,7 +145,7 @@ int virNetDevExists(const char *ifname)
* Returns 0 in case of success or -1 on failure
*/
int virNetDevSetMAC(const char *ifname,
- const unsigned char *macaddr)
+ const virMacAddrPtr macaddr)
{
int fd = -1;
int ret = -1;
@@ -162,7 +162,7 @@ int virNetDevSetMAC(const char *ifname,
goto cleanup;
}
- memcpy(ifr.ifr_hwaddr.sa_data, macaddr, VIR_MAC_BUFLEN);
+ virMacAddrGetRaw(macaddr, (unsigned char *)ifr.ifr_hwaddr.sa_data);
if (ioctl(fd, SIOCSIFHWADDR, &ifr) < 0) {
virReportSystemError(errno,
@@ -179,7 +179,7 @@ cleanup:
}
#else
int virNetDevSetMAC(const char *ifname,
- const unsigned char *macaddr ATTRIBUTE_UNUSED)
+ const virMacAddrPtr macaddr ATTRIBUTE_UNUSED)
{
virReportSystemError(ENOSYS,
_("Cannot set interface MAC on '%s'"),
@@ -193,14 +193,14 @@ int virNetDevSetMAC(const char *ifname,
/**
* virNetDevGetMAC:
* @ifname: interface name to set MTU for
- * @macaddr: MAC address (VIR_MAC_BUFLEN in size)
+ * @macaddr: MAC address
*
* This function gets the @macaddr for a given interface @ifname.
*
* Returns 0 in case of success or -1 on failure
*/
int virNetDevGetMAC(const char *ifname,
- unsigned char *macaddr)
+ virMacAddrPtr macaddr)
{
int fd = -1;
int ret = -1;
@@ -216,7 +216,7 @@ int virNetDevGetMAC(const char *ifname,
goto cleanup;
}
- memcpy(macaddr, ifr.ifr_hwaddr.sa_data, VIR_MAC_BUFLEN);
+ virMacAddrSetRaw(macaddr, (unsigned char *)ifr.ifr_hwaddr.sa_data);
ret = 0;
@@ -226,7 +226,7 @@ cleanup:
}
#else
int virNetDevGetMAC(const char *ifname,
- unsigned char *macaddr ATTRIBUTE_UNUSED)
+ virMacAddrPtr macaddr ATTRIBUTE_UNUSED)
{
virReportSystemError(ENOSYS,
_("Cannot get interface MAC on '%s'"),
@@ -248,14 +248,14 @@ int virNetDevGetMAC(const char *ifname,
*/
int
virNetDevReplaceMacAddress(const char *linkdev,
- const unsigned char *macaddress,
+ const virMacAddrPtr macaddress,
const char *stateDir)
{
- unsigned char oldmac[6];
+ virMacAddr oldmac;
char *path = NULL;
char macstr[VIR_MAC_STRING_BUFLEN];
- if (virNetDevGetMAC(linkdev, oldmac) < 0)
+ if (virNetDevGetMAC(linkdev, &oldmac) < 0)
return -1;
@@ -265,7 +265,7 @@ virNetDevReplaceMacAddress(const char *l
virReportOOMError();
return -1;
}
- virMacAddrFormat(oldmac, macstr);
+ virMacAddrFormat(&oldmac, macstr);
if (virFileWriteStr(path, macstr, O_CREAT|O_TRUNC|O_WRONLY) < 0) {
virReportSystemError(errno, _("Unable to preserve mac for %s"),
linkdev);
@@ -294,7 +294,7 @@ virNetDevRestoreMacAddress(const char *l
char *oldmacname = NULL;
char *macstr = NULL;
char *path = NULL;
- unsigned char oldmac[6];
+ virMacAddr oldmac;
if (virAsprintf(&path, "%s/%s",
stateDir,
@@ -306,7 +306,7 @@ virNetDevRestoreMacAddress(const char *l
if (virFileReadAll(path, VIR_MAC_STRING_BUFLEN, &macstr) < 0)
return -1;
- if (virMacAddrParse(macstr, &oldmac[0]) != 0) {
+ if (virMacAddrParse(macstr, &oldmac) != 0) {
virNetDevError(VIR_ERR_INTERNAL_ERROR,
_("Cannot parse MAC address from '%s'"),
oldmacname);
@@ -315,7 +315,7 @@ virNetDevRestoreMacAddress(const char *l
}
/*reset mac and remove file-ignore results*/
- rc = virNetDevSetMAC(linkdev, oldmac);
+ rc = virNetDevSetMAC(linkdev, &oldmac);
ignore_value(unlink(path));
VIR_FREE(macstr);
@@ -876,7 +876,7 @@ int virNetDevGetIPv4Address(const char *
*/
#if defined(HAVE_STRUCT_IFREQ)
int virNetDevValidateConfig(const char *ifname,
- const unsigned char *macaddr, int ifindex)
+ const virMacAddrPtr macaddr, int ifindex)
{
int fd = -1;
int ret = -1;
@@ -906,7 +906,8 @@ int virNetDevValidateConfig(const char *
goto cleanup;
}
- if (memcmp(&ifr.ifr_hwaddr.sa_data, macaddr, VIR_MAC_BUFLEN) != 0) {
+ if (virMacAddrCmpRaw(macaddr,
+ (unsigned char *)ifr.ifr_hwaddr.sa_data) != 0) {
ret = 0;
goto cleanup;
}
@@ -1333,7 +1334,7 @@ buffer_too_small:
static int
virNetDevSetVfConfig(const char *ifname, int ifindex, int vf,
- bool nltarget_kernel, const unsigned char *macaddr,
+ bool nltarget_kernel, const virMacAddrPtr macaddr,
int vlanid, uint32_t (*getPidFunc)(void))
{
int rc = -1;
@@ -1378,7 +1379,7 @@ virNetDevSetVfConfig(const char *ifname,
.mac = { 0, },
};
- memcpy(ifla_vf_mac.mac, macaddr, VIR_MAC_BUFLEN);
+ virMacAddrGetRaw(macaddr, ifla_vf_mac.mac);
if (nla_put(nl_msg, IFLA_VF_MAC, sizeof(ifla_vf_mac),
&ifla_vf_mac) < 0)
@@ -1456,7 +1457,7 @@ buffer_too_small:
}
static int
-virNetDevParseVfConfig(struct nlattr **tb, int32_t vf, unsigned char *mac,
+virNetDevParseVfConfig(struct nlattr **tb, int32_t vf, virMacAddrPtr mac,
int *vlanid)
{
const char *msg = NULL;
@@ -1483,7 +1484,7 @@ virNetDevParseVfConfig(struct nlattr **t
if (tb[IFLA_VF_MAC]) {
vf_mac = RTA_DATA(tb_vf[IFLA_VF_MAC]);
if (vf_mac && vf_mac->vf == vf) {
- memcpy(mac, vf_mac->mac, VIR_MAC_BUFLEN);
+ virMacAddrSetRaw(mac, vf_mac->mac);
found = 1;
}
}
@@ -1510,7 +1511,7 @@ cleanup:
}
static int
-virNetDevGetVfConfig(const char *ifname, int vf, unsigned char *mac,
+virNetDevGetVfConfig(const char *ifname, int vf, virMacAddrPtr mac,
int *vlanid)
{
int rc = -1;
@@ -1531,17 +1532,17 @@ virNetDevGetVfConfig(const char *ifname,
static int
virNetDevReplaceVfConfig(const char *pflinkdev, int vf,
- const unsigned char *macaddress,
+ const virMacAddrPtr macaddress,
int vlanid,
const char *stateDir)
{
- unsigned char oldmac[6];
+ virMacAddr oldmac;
int oldvlanid = -1;
char *path = NULL;
char macstr[VIR_MAC_STRING_BUFLEN];
int ifindex = -1;
- if (virNetDevGetVfConfig(pflinkdev, vf, oldmac, &oldvlanid) < 0)
+ if (virNetDevGetVfConfig(pflinkdev, vf, &oldmac, &oldvlanid) < 0)
return -1;
if (virAsprintf(&path, "%s/%s_vf%d",
@@ -1550,7 +1551,7 @@ virNetDevReplaceVfConfig(const char *pfl
return -1;
}
- virMacAddrFormat(oldmac, macstr);
+ virMacAddrFormat(&oldmac, macstr);
if (virFileWriteStr(path, macstr, O_CREAT|O_TRUNC|O_WRONLY) < 0) {
virReportSystemError(errno, _("Unable to preserve mac for pf = %s,"
" vf = %d"), pflinkdev, vf);
@@ -1571,7 +1572,7 @@ virNetDevRestoreVfConfig(const char *pfl
int rc = -1;
char *macstr = NULL;
char *path = NULL;
- unsigned char oldmac[6];
+ virMacAddr oldmac;
int vlanid = -1;
int ifindex = -1;
@@ -1585,7 +1586,7 @@ virNetDevRestoreVfConfig(const char *pfl
goto cleanup;
}
- if (virMacAddrParse(macstr, &oldmac[0]) != 0) {
+ if (virMacAddrParse(macstr, &oldmac) != 0) {
virNetDevError(VIR_ERR_INTERNAL_ERROR,
_("Cannot parse MAC address from '%s'"),
macstr);
@@ -1594,7 +1595,7 @@ virNetDevRestoreVfConfig(const char *pfl
/*reset mac and remove file-ignore results*/
rc = virNetDevSetVfConfig(pflinkdev, ifindex, vf, true,
- oldmac, vlanid, NULL);
+ &oldmac, vlanid, NULL);
ignore_value(unlink(path));
cleanup:
@@ -1617,7 +1618,7 @@ cleanup:
*/
int
virNetDevReplaceNetConfig(char *linkdev, int vf,
- const unsigned char *macaddress, int vlanid,
+ const virMacAddrPtr macaddress, int vlanid,
char *stateDir)
{
if (vf == -1)
Index: libvirt-acl/src/util/virnetdev.h
===================================================================
--- libvirt-acl.orig/src/util/virnetdev.h
+++ libvirt-acl/src/util/virnetdev.h
@@ -25,6 +25,7 @@
# include "virsocketaddr.h"
# include "virnetlink.h"
+# include "virmacaddr.h"
int virNetDevExists(const char *brname)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
@@ -49,14 +50,14 @@ int virNetDevGetIPv4Address(const char *
int virNetDevSetMAC(const char *ifname,
- const unsigned char *macaddr)
+ const virMacAddrPtr macaddr)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
int virNetDevGetMAC(const char *ifname,
- unsigned char *macaddr)
+ virMacAddrPtr macaddr)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
int virNetDevReplaceMacAddress(const char *linkdev,
- const unsigned char *macaddress,
+ const virMacAddrPtr macaddress,
const char *stateDir)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
ATTRIBUTE_RETURN_CHECK;
@@ -86,7 +87,7 @@ int virNetDevGetVLanID(const char *ifnam
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
int virNetDevValidateConfig(const char *ifname,
- const unsigned char *macaddr, int ifindex)
+ const virMacAddrPtr macaddr, int ifindex)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
int virNetDevIsVirtualFunction(const char *ifname)
@@ -113,7 +114,7 @@ int virNetDevLinkDump(const char *ifname
ATTRIBUTE_RETURN_CHECK;
int virNetDevReplaceNetConfig(char *linkdev, int vf,
- const unsigned char *macaddress, int vlanid,
+ const virMacAddrPtr macaddress, int vlanid,
char *stateDir)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(5);
Index: libvirt-acl/src/util/virnetdevmacvlan.c
===================================================================
--- libvirt-acl.orig/src/util/virnetdevmacvlan.c
+++ libvirt-acl/src/util/virnetdevmacvlan.c
@@ -95,7 +95,7 @@ VIR_ENUM_IMPL(virNetDevMacVLanMode, VIR_
int
virNetDevMacVLanCreate(const char *ifname,
const char *type,
- const unsigned char *macaddress,
+ const virMacAddrPtr macaddress,
const char *srcdev,
uint32_t macvlan_mode,
int *retry)
@@ -435,7 +435,7 @@ static const uint32_t modeMap[VIR_NETDEV
struct virNetlinkCallbackData {
char *cr_ifname;
virNetDevVPortProfilePtr virtPortProfile;
- unsigned char macaddress[VIR_MAC_BUFLEN];
+ virMacAddr macaddress;
char *linkdev;
int vf;
unsigned char vmuuid[VIR_UUID_BUFLEN];
@@ -589,13 +589,13 @@ virNetDevMacVLanVPortProfileCallback(uns
VIR_DEBUG("IFLA_VF_MAC = %2x:%2x:%2x:%2x:%2x:%2x",
m[0], m[1], m[2], m[3], m[4], m[5]);
- if (memcmp(calld->macaddress, m, VIR_MAC_BUFLEN))
+ if (virMacAddrCmpRaw(&calld->macaddress, mac->mac))
{
/* Repeat the same check for a broadcast mac */
int i;
for (i = 0;i < VIR_MAC_BUFLEN; i++) {
- if (calld->macaddress[i] != 0xff) {
+ if (calld->macaddress.addr[i] != 0xff) {
VIR_DEBUG("MAC address match failed (wasn't broadcast)");
return;
}
@@ -697,13 +697,13 @@ virNetDevMacVLanVPortProfileCallback(uns
VIR_INFO(" if: %s", calld->cr_ifname);
VIR_INFO(" lf: %s", calld->linkdev);
VIR_INFO(" mac: %02x:%02x:%02x:%02x:%02x:%02x",
- calld->macaddress[0], calld->macaddress[1],
- calld->macaddress[2], calld->macaddress[3],
- calld->macaddress[4], calld->macaddress[5]);
+ calld->macaddress.addr[0], calld->macaddress.addr[1],
+ calld->macaddress.addr[2], calld->macaddress.addr[3],
+ calld->macaddress.addr[4], calld->macaddress.addr[5]);
ignore_value(virNetDevVPortProfileAssociate(calld->cr_ifname,
calld->virtPortProfile,
- calld->macaddress,
+ &calld->macaddress,
calld->linkdev,
calld->vf,
calld->vmuuid,
@@ -746,7 +746,7 @@ virNetlinkCallbackDataFree(virNetlinkCal
*/
static void
virNetDevMacVLanVPortProfileDestroyCallback(int watch ATTRIBUTE_UNUSED,
- const unsigned char *macaddr ATTRIBUTE_UNUSED,
+ const virMacAddrPtr macaddr ATTRIBUTE_UNUSED,
void *opaque)
{
virNetlinkCallbackDataFree((virNetlinkCallbackDataPtr)opaque);
@@ -754,7 +754,7 @@ virNetDevMacVLanVPortProfileDestroyCallb
int
virNetDevMacVLanVPortProfileRegisterCallback(const char *ifname,
- const unsigned char *macaddress,
+ const virMacAddrPtr macaddress,
const char *linkdev,
const unsigned char *vmuuid,
virNetDevVPortProfilePtr virtPortProfile,
@@ -770,7 +770,7 @@ virNetDevMacVLanVPortProfileRegisterCall
if (VIR_ALLOC(calld->virtPortProfile) < 0)
goto memory_error;
memcpy(calld->virtPortProfile, virtPortProfile, sizeof(*virtPortProfile));
- memcpy(calld->macaddress, macaddress, sizeof(calld->macaddress));
+ virMacAddrSet(&calld->macaddress, macaddress);
if ((calld->linkdev = strdup(linkdev)) == NULL)
goto memory_error;
memcpy(calld->vmuuid, vmuuid, sizeof(calld->vmuuid));
@@ -813,7 +813,7 @@ error:
* otherwise returns 0; returns -1 on error.
*/
int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname,
- const unsigned char *macaddress,
+ const virMacAddrPtr macaddress,
const char *linkdev,
enum virNetDevMacVLanMode mode,
bool withTap,
@@ -980,7 +980,7 @@ link_del_exit:
* were provided.
*/
int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname,
- const unsigned char *macaddr,
+ const virMacAddrPtr macaddr,
const char *linkdev,
int mode,
virNetDevVPortProfilePtr virtPortProfile,
@@ -1025,7 +1025,7 @@ int virNetDevMacVLanDeleteWithVPortProfi
* Returns 0; returns -1 on error.
*/
int virNetDevMacVLanRestartWithVPortProfile(const char *cr_ifname,
- const unsigned char *macaddress,
+ const virMacAddrPtr macaddress,
const char *linkdev,
const unsigned char *vmuuid,
virNetDevVPortProfilePtr virtPortProfile,
@@ -1055,7 +1055,7 @@ error:
#else /* ! WITH_MACVTAP */
int virNetDevMacVLanCreate(const char *ifname ATTRIBUTE_UNUSED,
const char *type ATTRIBUTE_UNUSED,
- const unsigned char *macaddress ATTRIBUTE_UNUSED,
+ const virMacAddrPtr macaddress ATTRIBUTE_UNUSED,
const char *srcdev ATTRIBUTE_UNUSED,
uint32_t macvlan_mode ATTRIBUTE_UNUSED,
int *retry ATTRIBUTE_UNUSED)
@@ -1073,7 +1073,7 @@ int virNetDevMacVLanDelete(const char *i
}
int virNetDevMacVLanCreateWithVPortProfile(const char *ifname ATTRIBUTE_UNUSED,
- const unsigned char *macaddress ATTRIBUTE_UNUSED,
+ const virMacAddrPtr macaddress ATTRIBUTE_UNUSED,
const char *linkdev ATTRIBUTE_UNUSED,
enum virNetDevMacVLanMode mode ATTRIBUTE_UNUSED,
bool withTap ATTRIBUTE_UNUSED,
@@ -1091,7 +1091,7 @@ int virNetDevMacVLanCreateWithVPortProfi
}
int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname ATTRIBUTE_UNUSED,
- const unsigned char *macaddress ATTRIBUTE_UNUSED,
+ const virMacAddrPtr macaddress ATTRIBUTE_UNUSED,
const char *linkdev ATTRIBUTE_UNUSED,
int mode ATTRIBUTE_UNUSED,
virNetDevVPortProfilePtr virtPortProfile ATTRIBUTE_UNUSED,
@@ -1103,7 +1103,7 @@ int virNetDevMacVLanDeleteWithVPortProfi
}
int virNetDevMacVLanRestartWithVPortProfile(const char *cr_ifname ATTRIBUTE_UNUSED,
- const unsigned char *macaddress ATTRIBUTE_UNUSED,
+ const virMacAddrPtr macaddress ATTRIBUTE_UNUSED,
const char *linkdev ATTRIBUTE_UNUSED,
const unsigned char *vmuuid ATTRIBUTE_UNUSED,
virNetDevVPortProfilePtr virtPortProfile ATTRIBUTE_UNUSED,
@@ -1115,7 +1115,7 @@ int virNetDevMacVLanRestartWithVPortProf
}
int virNetDevMacVLanVPortProfileRegisterCallback(const char *ifname ATTRIBUTE_UNUSED,
- const unsigned char *macaddress ATTRIBUTE_UNUSED,
+ const virMacAddrPtr macaddress ATTRIBUTE_UNUSED,
const char *linkdev ATTRIBUTE_UNUSED,
const unsigned char *vmuuid ATTRIBUTE_UNUSED,
virNetDevVPortProfilePtr virtPortProfile ATTRIBUTE_UNUSED,
Index: libvirt-acl/src/util/virnetdevmacvlan.h
===================================================================
--- libvirt-acl.orig/src/util/virnetdevmacvlan.h
+++ libvirt-acl/src/util/virnetdevmacvlan.h
@@ -24,6 +24,7 @@
# define __UTIL_MACVTAP_H__
# include "internal.h"
+# include "virmacaddr.h"
# include "virsocketaddr.h"
# include "virnetdevbandwidth.h"
# include "virnetdevvportprofile.h"
@@ -41,7 +42,7 @@ VIR_ENUM_DECL(virNetDevMacVLanMode)
int virNetDevMacVLanCreate(const char *ifname,
const char *type,
- const unsigned char *macaddress,
+ const virMacAddrPtr macaddress,
const char *srcdev,
uint32_t macvlan_mode,
int *retry)
@@ -52,7 +53,7 @@ int virNetDevMacVLanDelete(const char *i
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
int virNetDevMacVLanCreateWithVPortProfile(const char *ifname,
- const unsigned char *macaddress,
+ const virMacAddrPtr macaddress,
const char *linkdev,
enum virNetDevMacVLanMode mode,
bool withTap,
@@ -67,7 +68,7 @@ int virNetDevMacVLanCreateWithVPortProfi
ATTRIBUTE_NONNULL(9) ATTRIBUTE_NONNULL(11) ATTRIBUTE_RETURN_CHECK;
int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname,
- const unsigned char *macaddress,
+ const virMacAddrPtr macaddress,
const char *linkdev,
int mode,
virNetDevVPortProfilePtr virtPortProfile,
@@ -76,7 +77,7 @@ int virNetDevMacVLanDeleteWithVPortProfi
ATTRIBUTE_NONNULL(6) ATTRIBUTE_RETURN_CHECK;
int virNetDevMacVLanRestartWithVPortProfile(const char *cr_ifname,
- const unsigned char *macaddress,
+ const virMacAddrPtr macaddress,
const char *linkdev,
const unsigned char *vmuuid,
virNetDevVPortProfilePtr virtPortProfile,
@@ -85,7 +86,7 @@ int virNetDevMacVLanRestartWithVPortProf
ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
int virNetDevMacVLanVPortProfileRegisterCallback(const char *ifname,
- const unsigned char *macaddress ,
+ const virMacAddrPtr macaddress ,
const char *linkdev,
const unsigned char *vmuuid,
virNetDevVPortProfilePtr virtPortProfile,
Index: libvirt-acl/src/util/virnetdevvportprofile.h
===================================================================
--- libvirt-acl.orig/src/util/virnetdevvportprofile.h
+++ libvirt-acl/src/util/virnetdevvportprofile.h
@@ -28,6 +28,7 @@
# include "internal.h"
# include "uuid.h"
# include "util.h"
+# include "virmacaddr.h"
# define LIBVIRT_IFLA_VF_PORT_PROFILE_MAX 40
@@ -83,7 +84,7 @@ bool virNetDevVPortProfileEqual(virNetDe
int virNetDevVPortProfileAssociate(const char *ifname,
const virNetDevVPortProfilePtr virtPort,
- const unsigned char *macaddr,
+ const virMacAddrPtr macaddr,
const char *linkdev,
int vf,
const unsigned char *vmuuid,
@@ -94,7 +95,7 @@ int virNetDevVPortProfileAssociate(const
int virNetDevVPortProfileDisassociate(const char *ifname,
const virNetDevVPortProfilePtr virtPort,
- const unsigned char *macaddr,
+ const virMacAddrPtr macaddr,
const char *linkdev,
int vf,
enum virNetDevVPortProfileOp vmOp)
Index: libvirt-acl/src/util/virnetlink.c
===================================================================
--- libvirt-acl.orig/src/util/virnetlink.c
+++ libvirt-acl/src/util/virnetlink.c
@@ -56,7 +56,7 @@ struct virNetlinkEventHandle {
virNetlinkEventHandleCallback handleCB;
virNetlinkEventRemoveCallback removeCB;
void *opaque;
- unsigned char macaddr[VIR_MAC_BUFLEN];
+ virMacAddr macaddr;
int deleted;
};
@@ -278,7 +278,7 @@ virNetlinkEventRemoveClientPrimitive(siz
if (removeCB) {
(removeCB)(server->handles[i].watch,
- server->handles[i].macaddr,
+ &server->handles[i].macaddr,
server->handles[i].opaque);
}
server->handles[i].deleted = VIR_NETLINK_HANDLE_DELETED;
@@ -506,7 +506,7 @@ error_locked:
int
virNetlinkEventAddClient(virNetlinkEventHandleCallback handleCB,
virNetlinkEventRemoveCallback removeCB,
- void *opaque, const unsigned char *macaddr)
+ void *opaque, const virMacAddrPtr macaddr)
{
int i, r, ret = -1;
virNetlinkEventSrvPrivatePtr srv = server;
@@ -548,9 +548,10 @@ addentry:
srv->handles[r].opaque = opaque;
srv->handles[r].deleted = VIR_NETLINK_HANDLE_VALID;
if (macaddr)
- memcpy(srv->handles[r].macaddr, macaddr, VIR_MAC_BUFLEN);
+ virMacAddrSet(&srv->handles[r].macaddr, macaddr);
else
- memset(srv->handles[r].macaddr, 0, VIR_MAC_BUFLEN);
+ virMacAddrSetRaw(&srv->handles[r].macaddr,
+ (unsigned char[VIR_MAC_BUFLEN]){0,0,0,0,0,0});
VIR_DEBUG("added client to loop slot: %d. with macaddr ptr=%p", r, macaddr);
@@ -573,7 +574,7 @@ error:
* Returns -1 if the file handle was not registered, 0 upon success
*/
int
-virNetlinkEventRemoveClient(int watch, const unsigned char *macaddr)
+virNetlinkEventRemoveClient(int watch, const virMacAddrPtr macaddr)
{
int i;
int ret = -1;
@@ -594,7 +595,7 @@ virNetlinkEventRemoveClient(int watch, c
if ((watch && srv->handles[i].watch == watch) ||
(!watch &&
- memcmp(macaddr, srv->handles[i].macaddr, VIR_MAC_BUFLEN) == 0)) {
+ virMacAddrCmp(macaddr, &srv->handles[i].macaddr) == 0)) {
VIR_DEBUG("removed client: %d by %s.",
srv->handles[i].watch, watch ? "index" : "mac");
Index: libvirt-acl/src/util/virnetlink.h
===================================================================
--- libvirt-acl.orig/src/util/virnetlink.h
+++ libvirt-acl/src/util/virnetlink.h
@@ -22,6 +22,7 @@
# include "config.h"
# include "internal.h"
+# include "virmacaddr.h"
# include <stdint.h>
@@ -46,7 +47,7 @@ int virNetlinkCommand(struct nl_msg *nl_
typedef void (*virNetlinkEventHandleCallback)(unsigned char *msg, int length, struct sockaddr_nl *peer, bool *handled, void *opaque);
-typedef void (*virNetlinkEventRemoveCallback)(int watch, const unsigned char *macaddr, void *opaque);
+typedef void (*virNetlinkEventRemoveCallback)(int watch, const virMacAddrPtr macaddr, void *opaque);
/**
* stopNetlinkEventServer: stop the monitor to receive netlink messages for libvirtd
@@ -73,11 +74,11 @@ int virNetlinkEventServiceLocalPid(void)
*/
int virNetlinkEventAddClient(virNetlinkEventHandleCallback handleCB,
virNetlinkEventRemoveCallback removeCB,
- void *opaque, const unsigned char *macaddr);
+ void *opaque, const virMacAddrPtr macaddr);
/**
* virNetlinkEventRemoveClient: unregister a callback from a netlink monitor
*/
-int virNetlinkEventRemoveClient(int watch, const unsigned char *macaddr);
+int virNetlinkEventRemoveClient(int watch, const virMacAddrPtr macaddr);
#endif /* __VIR_NETLINK_H__ */
Index: libvirt-acl/src/conf/capabilities.c
===================================================================
--- libvirt-acl.orig/src/conf/capabilities.c
+++ libvirt-acl/src/conf/capabilities.c
@@ -859,14 +859,14 @@ virCapabilitiesFormatXML(virCapsPtr caps
extern void
virCapabilitiesSetMacPrefix(virCapsPtr caps,
- unsigned char *prefix)
+ const unsigned char prefix[VIR_MAC_PREFIX_BUFLEN])
{
memcpy(caps->macPrefix, prefix, sizeof(caps->macPrefix));
}
extern void
virCapabilitiesGenerateMac(virCapsPtr caps,
- unsigned char *mac)
+ virMacAddrPtr mac)
{
virMacAddrGenerate(caps->macPrefix, mac);
}
Index: libvirt-acl/src/conf/capabilities.h
===================================================================
--- libvirt-acl.orig/src/conf/capabilities.h
+++ libvirt-acl/src/conf/capabilities.h
@@ -172,11 +172,11 @@ virCapabilitiesFreeNUMAInfo(virCapsPtr c
extern void
virCapabilitiesSetMacPrefix(virCapsPtr caps,
- unsigned char *prefix);
+ const unsigned char prefix[VIR_MAC_PREFIX_BUFLEN]);
extern void
virCapabilitiesGenerateMac(virCapsPtr caps,
- unsigned char *mac);
+ virMacAddrPtr mac);
extern void
virCapabilitiesSetEmulatorRequired(virCapsPtr caps);
Index: libvirt-acl/src/conf/domain_audit.c
===================================================================
--- libvirt-acl.orig/src/conf/domain_audit.c
+++ libvirt-acl/src/conf/domain_audit.c
@@ -160,9 +160,9 @@ virDomainAuditNet(virDomainObjPtr vm,
virUUIDFormat(vm->def->uuid, uuidstr);
if (oldDef)
- virMacAddrFormat(oldDef->mac, oldMacstr);
+ virMacAddrFormat(&oldDef->mac, oldMacstr);
if (newDef)
- virMacAddrFormat(newDef->mac, newMacstr);
+ virMacAddrFormat(&newDef->mac, newMacstr);
if (!(vmname = virAuditEncode("vm", vm->def->name))) {
VIR_WARN("OOM while encoding audit message");
return;
@@ -206,7 +206,7 @@ virDomainAuditNetDevice(virDomainDefPtr
const char *virt;
virUUIDFormat(vmDef->uuid, uuidstr);
- virMacAddrFormat(netDef->mac, macstr);
+ virMacAddrFormat(&netDef->mac, macstr);
rdev = virDomainAuditGetRdev(device);
if (!(vmname = virAuditEncode("vm", vmDef->name)) ||
Index: libvirt-acl/src/conf/domain_conf.c
===================================================================
--- libvirt-acl.orig/src/conf/domain_conf.c
+++ libvirt-acl/src/conf/domain_conf.c
@@ -4641,20 +4641,20 @@ virDomainNetDefParseXML(virCapsPtr caps,
}
if (macaddr) {
- if (virMacAddrParse((const char *)macaddr, def->mac) < 0) {
+ if (virMacAddrParse((const char *)macaddr, &def->mac) < 0) {
virDomainReportError(VIR_ERR_XML_ERROR,
_("unable to parse mac address '%s'"),
(const char *)macaddr);
goto error;
}
- if (virMacAddrIsMulticast(def->mac)) {
+ if (virMacAddrIsMulticast(&def->mac)) {
virDomainReportError(VIR_ERR_XML_ERROR,
_("expected unicast mac address, found multicast '%s'"),
(const char *)macaddr);
goto error;
}
} else {
- virCapabilitiesGenerateMac(caps, def->mac);
+ virCapabilitiesGenerateMac(caps, &def->mac);
}
if (devaddr) {
@@ -7443,12 +7443,12 @@ int virDomainNetInsert(virDomainDefPtr d
return 0;
}
-int virDomainNetIndexByMac(virDomainDefPtr def, const unsigned char *mac)
+int virDomainNetIndexByMac(virDomainDefPtr def, const virMacAddrPtr mac)
{
int i;
for (i = 0; i < def->nnets; i++)
- if (!memcmp(def->nets[i]->mac, mac, VIR_MAC_BUFLEN))
+ if (!virMacAddrCmp(&def->nets[i]->mac, mac))
return i;
return -1;
}
@@ -7489,7 +7489,7 @@ virDomainNetRemove(virDomainDefPtr def,
}
virDomainNetDefPtr
-virDomainNetRemoveByMac(virDomainDefPtr def, const unsigned char *mac)
+virDomainNetRemoveByMac(virDomainDefPtr def, const virMacAddrPtr mac)
{
int i = virDomainNetIndexByMac(def, mac);
@@ -9712,14 +9712,14 @@ static bool virDomainNetDefCheckABIStabi
{
bool identical = false;
- if (memcmp(src->mac, dst->mac, VIR_MAC_BUFLEN) != 0) {
+ if (virMacAddrCmp(&src->mac, &dst->mac) != 0) {
virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target network card mac %02x:%02x:%02x:%02x:%02x:%02x"
"does not match source %02x:%02x:%02x:%02x:%02x:%02x"),
- dst->mac[0], dst->mac[1], dst->mac[2],
- dst->mac[3], dst->mac[4], dst->mac[5],
- src->mac[0], src->mac[1], src->mac[2],
- src->mac[3], src->mac[4], src->mac[5]);
+ dst->mac.addr[0], dst->mac.addr[1], dst->mac.addr[2],
+ dst->mac.addr[3], dst->mac.addr[4], dst->mac.addr[5],
+ src->mac.addr[0], src->mac.addr[1], src->mac.addr[2],
+ src->mac.addr[3], src->mac.addr[4], src->mac.addr[5]);
goto cleanup;
}
@@ -11575,8 +11575,8 @@ virDomainNetDefFormat(virBufferPtr buf,
virBufferAsprintf(buf,
" <mac address='%02x:%02x:%02x:%02x:%02x:%02x'/>\n",
- def->mac[0], def->mac[1], def->mac[2],
- def->mac[3], def->mac[4], def->mac[5]);
+ def->mac.addr[0], def->mac.addr[1], def->mac.addr[2],
+ def->mac.addr[3], def->mac.addr[4], def->mac.addr[5]);
switch (def->type) {
case VIR_DOMAIN_NET_TYPE_NETWORK:
@@ -15146,15 +15146,15 @@ virDomainNetFind(virDomainDefPtr def, co
{
bool isMac = false;
virDomainNetDefPtr net = NULL;
- unsigned char mac[VIR_MAC_BUFLEN];
+ virMacAddr mac;
int i;
- if (virMacAddrParse(device, mac) == 0)
+ if (virMacAddrParse(device, &mac) == 0)
isMac = true;
if (isMac) {
for (i = 0; i < def->nnets; i++) {
- if (memcmp(mac, def->nets[i]->mac, VIR_MAC_BUFLEN) == 0) {
+ if (virMacAddrCmp(&mac, &def->nets[i]->mac) == 0) {
net = def->nets[i];
break;
}
Index: libvirt-acl/src/conf/network_conf.c
===================================================================
--- libvirt-acl.orig/src/conf/network_conf.c
+++ libvirt-acl/src/conf/network_conf.c
@@ -420,19 +420,19 @@ virNetworkDHCPRangeDefParseXML(const cha
} else if (cur->type == XML_ELEMENT_NODE &&
xmlStrEqual(cur->name, BAD_CAST "host")) {
char *mac = NULL, *name = NULL, *ip;
- unsigned char addr[6];
+ virMacAddr addr;
virSocketAddr inaddr;
mac = virXMLPropString(cur, "mac");
if (mac != NULL) {
- if (virMacAddrParse(mac, &addr[0]) < 0) {
+ if (virMacAddrParse(mac, &addr) < 0) {
virNetworkReportError(VIR_ERR_XML_ERROR,
_("Cannot parse MAC address '%s' in network '%s'"),
mac, networkName);
VIR_FREE(mac);
return -1;
}
- if (virMacAddrIsMulticast(addr)) {
+ if (virMacAddrIsMulticast(&addr)) {
virNetworkReportError(VIR_ERR_XML_ERROR,
_("expected unicast mac address, found multicast '%s' in network '%s'"),
(const char *)mac, networkName);
@@ -989,14 +989,14 @@ virNetworkDefParseXML(xmlXPathContextPtr
tmp = virXPathString("string(./mac[1]/@address)", ctxt);
if (tmp) {
- if (virMacAddrParse(tmp, def->mac) < 0) {
+ if (virMacAddrParse(tmp, &def->mac) < 0) {
virNetworkReportError(VIR_ERR_XML_ERROR,
_("Invalid bridge mac address '%s' in network '%s'"),
tmp, def->name);
VIR_FREE(tmp);
goto error;
}
- if (virMacAddrIsMulticast(def->mac)) {
+ if (virMacAddrIsMulticast(&def->mac)) {
virNetworkReportError(VIR_ERR_XML_ERROR,
_("Invalid multicast bridge mac address '%s' in network '%s'"),
tmp, def->name);
@@ -1520,7 +1520,7 @@ char *virNetworkDefFormat(const virNetwo
if (def->mac_specified) {
char macaddr[VIR_MAC_STRING_BUFLEN];
- virMacAddrFormat(def->mac, macaddr);
+ virMacAddrFormat(&def->mac, macaddr);
virBufferAsprintf(&buf, " <mac address='%s'/>\n", macaddr);
}
@@ -1848,7 +1848,7 @@ void virNetworkSetBridgeMacAddr(virNetwo
* autogenerate a random one.
*/
virMacAddrGenerate((unsigned char[]){ 0x52, 0x54, 0 },
- def->mac);
+ &def->mac);
def->mac_specified = true;
}
}
Index: libvirt-acl/src/conf/network_conf.h
===================================================================
--- libvirt-acl.orig/src/conf/network_conf.h
+++ libvirt-acl/src/conf/network_conf.h
@@ -154,7 +154,7 @@ struct _virNetworkDef {
char *domain;
unsigned long delay; /* Bridge forward delay (ms) */
unsigned int stp :1; /* Spanning tree protocol */
- unsigned char mac[VIR_MAC_BUFLEN]; /* mac address of bridge device */
+ virMacAddr mac; /* mac address of bridge device */
bool mac_specified;
int forwardType; /* One of virNetworkForwardType constants */
Index: libvirt-acl/src/conf/nwfilter_conf.c
===================================================================
--- libvirt-acl.orig/src/conf/nwfilter_conf.c
+++ libvirt-acl/src/conf/nwfilter_conf.c
@@ -1775,15 +1775,6 @@ static const virAttributes virAttr[] = {
PROTOCOL_ENTRY_LAST
};
-
-static int
-virNWMACAddressParser(const char *input,
- nwMACAddressPtr output)
-{
- return virMacAddrParse(input, &output->addr[0]);
-}
-
-
static int
virNWFilterRuleDetailsParse(xmlNodePtr node,
virNWFilterRuleDefPtr nwf,
@@ -1916,8 +1907,8 @@ virNWFilterRuleDetailsParse(xmlNodePtr n
break;
case DATATYPE_MACADDR:
- if (virNWMACAddressParser(prop,
- &item->u.macaddr) < 0) {
+ if (virMacAddrParse(prop,
+ &item->u.macaddr) < 0) {
rc = -1;
}
found = 1;
@@ -1925,8 +1916,8 @@ virNWFilterRuleDetailsParse(xmlNodePtr n
case DATATYPE_MACMASK:
validator = checkMACMask;
- if (virNWMACAddressParser(prop,
- &item->u.macaddr) < 0) {
+ if (virMacAddrParse(prop,
+ &item->u.macaddr) < 0) {
rc = -1;
}
data.v = &item->u.macaddr;
Index: libvirt-acl/src/conf/nwfilter_conf.h
===================================================================
--- libvirt-acl.orig/src/conf/nwfilter_conf.h
+++ libvirt-acl/src/conf/nwfilter_conf.h
@@ -36,6 +36,7 @@
# include "xml.h"
# include "buf.h"
# include "virsocketaddr.h"
+# include "virmacaddr.h"
/* XXX
* The config parser/structs should not be using platform specific
@@ -113,13 +114,6 @@ enum attrDatatype {
# define NWFILTER_MAC_BGA "01:80:c2:00:00:00"
-typedef struct _nwMACAddress nwMACAddress;
-typedef nwMACAddress *nwMACAddressPtr;
-struct _nwMACAddress {
- unsigned char addr[6];
-};
-
-
typedef struct _nwItemDesc nwItemDesc;
typedef nwItemDesc *nwItemDescPtr;
struct _nwItemDesc {
@@ -127,7 +121,7 @@ struct _nwItemDesc {
virNWFilterVarAccessPtr varAccess;
enum attrDatatype datatype;
union {
- nwMACAddress macaddr;
+ virMacAddr macaddr;
virSocketAddr ipaddr;
bool boolean;
uint8_t u8;
@@ -633,10 +627,10 @@ typedef int (*virNWFilterRuleDisplayInst
typedef int (*virNWFilterCanApplyBasicRules)(void);
typedef int (*virNWFilterApplyBasicRules)(const char *ifname,
- const unsigned char *macaddr);
+ const virMacAddrPtr macaddr);
typedef int (*virNWFilterApplyDHCPOnlyRules)(const char *ifname,
- const unsigned char *macaddr,
+ const virMacAddrPtr macaddr,
virNWFilterVarValuePtr dhcpsrvs,
bool leaveTemporary);
Index: libvirt-acl/src/conf/nwfilter_params.h
===================================================================
--- libvirt-acl.orig/src/conf/nwfilter_params.h
+++ libvirt-acl/src/conf/nwfilter_params.h
@@ -25,6 +25,7 @@
# include "virhash.h"
# include "buf.h"
+# include "virmacaddr.h"
enum virNWFilterVarValueType {
NWFILTER_VALUE_TYPE_SIMPLE,
Index: libvirt-acl/src/network/bridge_driver.c
===================================================================
--- libvirt-acl.orig/src/network/bridge_driver.c
+++ libvirt-acl/src/network/bridge_driver.c
@@ -1765,7 +1765,7 @@ networkStartNetworkVirtual(struct networ
goto err0;
}
if (virNetDevTapCreateInBridgePort(network->def->bridge,
- &macTapIfName, network->def->mac,
+ &macTapIfName, &network->def->mac,
NULL, NULL, NULL,
VIR_NETDEV_TAP_CREATE_USE_MAC_FOR_BRIDGE) < 0) {
VIR_FREE(macTapIfName);
Index: libvirt-acl/src/nwfilter/nwfilter_dhcpsnoop.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_dhcpsnoop.c
+++ libvirt-acl/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -484,7 +484,7 @@ virNWFilterSnoopIPLeaseInstallRule(virNW
req->ifindex,
req->linkdev,
req->nettype,
- req->macaddr,
+ &req->macaddr,
req->filtername,
req->vars,
req->driver);
@@ -875,7 +875,7 @@ virNWFilterSnoopReqLeaseDel(virNWFilterS
req->ifindex,
req->linkdev,
req->nettype,
- req->macaddr,
+ &req->macaddr,
req->filtername,
req->vars,
req->driver);
@@ -884,7 +884,7 @@ virNWFilterSnoopReqLeaseDel(virNWFilterS
virHashLookup(req->vars->hashTable, NWFILTER_VARNAME_DHCPSERVER);
if (req->techdriver &&
- req->techdriver->applyDHCPOnlyRules(req->ifname, req->macaddr,
+ req->techdriver->applyDHCPOnlyRules(req->ifname, &req->macaddr,
dhcpsrvrs, false) < 0) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
_("virNWFilterSnoopListDel failed"));
@@ -1071,7 +1071,7 @@ virNWFilterSnoopDHCPOpen(const char *ifn
char macaddr[VIR_MAC_STRING_BUFLEN];
const char *ext;
- virMacAddrFormat((unsigned char *)mac, macaddr);
+ virMacAddrFormat(mac, macaddr);
if (dir == PCAP_D_IN /* from VM */) {
/*
@@ -1560,7 +1560,7 @@ exit:
static void
virNWFilterSnoopIFKeyFMT(char *ifkey, const unsigned char *vmuuid,
- unsigned const char *macaddr)
+ const virMacAddrPtr macaddr)
{
virUUIDFormat(vmuuid, ifkey);
ifkey[VIR_UUID_STRING_BUFLEN - 1] = '-';
@@ -1573,7 +1573,7 @@ virNWFilterDHCPSnoopReq(virNWFilterTechD
const char *linkdev,
enum virDomainNetType nettype,
const unsigned char *vmuuid,
- const unsigned char *macaddr,
+ const virMacAddrPtr macaddr,
const char *filtername,
virNWFilterHashTablePtr filterparams,
virNWFilterDriverStatePtr driver)
@@ -1609,7 +1609,7 @@ virNWFilterDHCPSnoopReq(virNWFilterTechD
req->linkdev = linkdev ? strdup(linkdev) : NULL;
req->nettype = nettype;
req->ifname = strdup(ifname);
- memcpy(req->macaddr, macaddr, sizeof(req->macaddr));
+ virMacAddrSet(&req->macaddr, macaddr);
req->filtername = strdup(filtername);
req->vars = virNWFilterHashTableCreate(0);
@@ -1631,7 +1631,7 @@ virNWFilterDHCPSnoopReq(virNWFilterTechD
dhcpsrvrs = virHashLookup(filterparams->hashTable,
NWFILTER_VARNAME_DHCPSERVER);
- if (techdriver->applyDHCPOnlyRules(req->ifname, req->macaddr,
+ if (techdriver->applyDHCPOnlyRules(req->ifname, &req->macaddr,
dhcpsrvrs, false) < 0) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, _("applyDHCPOnlyRules "
"failed - spoofing not protected!"));
Index: libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_ebiptables_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -306,7 +306,7 @@ _printDataType(virNWFilterVarCombIterPtr
return -1;
}
- virMacAddrFormat(item->u.macaddr.addr, buf);
+ virMacAddrFormat(&item->u.macaddr, buf);
break;
case DATATYPE_IPV6MASK:
@@ -3189,7 +3189,7 @@ ebiptablesCanApplyBasicRules(void) {
*/
static int
ebtablesApplyBasicRules(const char *ifname,
- const unsigned char *macaddr)
+ const virMacAddrPtr macaddr)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
char chain[MAX_CHAINNAME_LENGTH];
@@ -3282,7 +3282,7 @@ tear_down_tmpebchains:
*/
static int
ebtablesApplyDHCPOnlyRules(const char *ifname,
- const unsigned char *macaddr,
+ const virMacAddrPtr macaddr,
virNWFilterVarValuePtr dhcpsrvrs,
bool leaveTemporary)
{
Index: libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_gentech_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c
@@ -656,7 +656,7 @@ virNWFilterInstantiate(const unsigned ch
virNWFilterHashTablePtr vars,
enum instCase useNewFilter, bool *foundNewFilter,
bool teardownOld,
- const unsigned char *macaddr,
+ const virMacAddrPtr macaddr,
virNWFilterDriverStatePtr driver,
bool forceWithPendingReq)
{
@@ -817,7 +817,7 @@ __virNWFilterInstantiateFilter(const uns
int ifindex,
const char *linkdev,
enum virDomainNetType nettype,
- const unsigned char *macaddr,
+ const virMacAddrPtr macaddr,
const char *filtername,
virNWFilterHashTablePtr filterparams,
enum instCase useNewFilter,
@@ -967,7 +967,7 @@ _virNWFilterInstantiateFilter(virConnect
ifindex,
linkdev,
net->type,
- net->mac,
+ &net->mac,
net->filter,
net->filterparams,
useNewFilter,
@@ -988,7 +988,7 @@ virNWFilterInstantiateFilterLate(const u
int ifindex,
const char *linkdev,
enum virDomainNetType nettype,
- const unsigned char *macaddr,
+ const virMacAddrPtr macaddr,
const char *filtername,
virNWFilterHashTablePtr filterparams,
virNWFilterDriverStatePtr driver)
Index: libvirt-acl/src/nwfilter/nwfilter_gentech_driver.h
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_gentech_driver.h
+++ libvirt-acl/src/nwfilter/nwfilter_gentech_driver.h
@@ -50,7 +50,7 @@ int virNWFilterInstantiateFilterLate(con
int ifindex,
const char *linkdev,
enum virDomainNetType nettype,
- const unsigned char *macaddr,
+ const virMacAddrPtr macaddr,
const char *filtername,
virNWFilterHashTablePtr filterparams,
virNWFilterDriverStatePtr driver);
Index: libvirt-acl/src/nwfilter/nwfilter_learnipaddr.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_learnipaddr.c
+++ libvirt-acl/src/nwfilter/nwfilter_learnipaddr.c
@@ -404,12 +404,12 @@ learnIPAddressThread(void *arg)
goto done;
}
- virMacAddrFormat(req->macaddr, macaddr);
+ virMacAddrFormat(&req->macaddr, macaddr);
switch (req->howDetect) {
case DETECT_DHCP:
if (techdriver->applyDHCPOnlyRules(req->ifname,
- req->macaddr,
+ &req->macaddr,
NULL, false) < 0) {
req->status = EINVAL;
goto done;
@@ -420,7 +420,7 @@ learnIPAddressThread(void *arg)
break;
default:
if (techdriver->applyBasicRules(req->ifname,
- req->macaddr) < 0) {
+ &req->macaddr) < 0) {
req->status = EINVAL;
goto done;
}
@@ -493,9 +493,7 @@ learnIPAddressThread(void *arg)
continue;
}
- if (memcmp(ether_hdr->ether_shost,
- req->macaddr,
- VIR_MAC_BUFLEN) == 0) {
+ if (virMacAddrCmpRaw(&req->macaddr, ether_hdr->ether_shost) == 0) {
/* packets from the VM */
if (etherType == ETHERTYPE_IP &&
@@ -530,9 +528,8 @@ learnIPAddressThread(void *arg)
break;
}
}
- } else if (memcmp(ether_hdr->ether_dhost,
- req->macaddr,
- VIR_MAC_BUFLEN) == 0) {
+ } else if (virMacAddrCmpRaw(&req->macaddr,
+ ether_hdr->ether_dhost) == 0) {
/* packets to the VM */
if (etherType == ETHERTYPE_IP &&
(header.len >= ethHdrSize +
@@ -554,9 +551,9 @@ learnIPAddressThread(void *arg)
struct dhcp *dhcp = (struct dhcp *)
((char *)udphdr + sizeof(udphdr));
if (dhcp->op == 2 /* BOOTREPLY */ &&
- !memcmp(&dhcp->chaddr[0],
- req->macaddr,
- 6)) {
+ virMacAddrCmpRaw(
+ &req->macaddr,
+ &dhcp->chaddr[0]) == 0) {
dhcp_opts_len = header.len -
(ethHdrSize + iphdr->ihl * 4 +
sizeof(struct udphdr) +
@@ -602,7 +599,7 @@ learnIPAddressThread(void *arg)
req->ifindex,
req->linkdev,
req->nettype,
- req->macaddr,
+ &req->macaddr,
req->filtername,
req->filterparams,
req->driver);
@@ -662,7 +659,7 @@ virNWFilterLearnIPAddress(virNWFilterTec
int ifindex,
const char *linkdev,
enum virDomainNetType nettype,
- const unsigned char *macaddr,
+ const virMacAddrPtr macaddr,
const char *filtername,
virNWFilterHashTablePtr filterparams,
virNWFilterDriverStatePtr driver,
@@ -720,7 +717,7 @@ virNWFilterLearnIPAddress(virNWFilterTec
req->ifindex = ifindex;
req->nettype = nettype;
- memcpy(req->macaddr, macaddr, sizeof(req->macaddr));
+ virMacAddrSet(&req->macaddr, macaddr);
req->driver = driver;
req->filterparams = ht;
ht = NULL;
@@ -758,7 +755,7 @@ virNWFilterLearnIPAddress(virNWFilterTec
int ifindex ATTRIBUTE_UNUSED,
const char *linkdev ATTRIBUTE_UNUSED,
enum virDomainNetType nettype ATTRIBUTE_UNUSED,
- const unsigned char *macaddr ATTRIBUTE_UNUSED,
+ const virMacAddrPtr macaddr ATTRIBUTE_UNUSED,
const char *filtername ATTRIBUTE_UNUSED,
virNWFilterHashTablePtr filterparams ATTRIBUTE_UNUSED,
virNWFilterDriverStatePtr driver ATTRIBUTE_UNUSED,
Index: libvirt-acl/src/nwfilter/nwfilter_learnipaddr.h
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_learnipaddr.h
+++ libvirt-acl/src/nwfilter/nwfilter_learnipaddr.h
@@ -40,7 +40,7 @@ struct _virNWFilterIPAddrLearnReq {
int ifindex;
char linkdev[IF_NAMESIZE];
enum virDomainNetType nettype;
- unsigned char macaddr[VIR_MAC_BUFLEN];
+ virMacAddr macaddr;
char *filtername;
virNWFilterHashTablePtr filterparams;
virNWFilterDriverStatePtr driver;
@@ -56,7 +56,7 @@ int virNWFilterLearnIPAddress(virNWFilte
int ifindex,
const char *linkdev,
enum virDomainNetType nettype,
- const unsigned char *macaddr,
+ const virMacAddrPtr macaddr,
const char *filtername,
virNWFilterHashTablePtr filterparams,
virNWFilterDriverStatePtr driver,
Index: libvirt-acl/src/openvz/openvz_conf.c
===================================================================
--- libvirt-acl.orig/src/openvz/openvz_conf.c
+++ libvirt-acl/src/openvz/openvz_conf.c
@@ -335,7 +335,7 @@ openvzReadNetworkConf(virDomainDefPtr de
_("MAC address %s too long for destination"), p);
goto error;
}
- if (virMacAddrParse(cpy_temp, net->mac) < 0) {
+ if (virMacAddrParse(cpy_temp, &net->mac) < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Wrong MAC address"));
goto error;
Index: libvirt-acl/src/openvz/openvz_driver.c
===================================================================
--- libvirt-acl.orig/src/openvz/openvz_driver.c
+++ libvirt-acl/src/openvz/openvz_driver.c
@@ -735,7 +735,7 @@ openvzDomainSetNetwork(virConnectPtr con
int rc = 0, narg;
const char *prog[OPENVZ_MAX_ARG];
char macaddr[VIR_MAC_STRING_BUFLEN];
- unsigned char host_mac[VIR_MAC_BUFLEN];
+ virMacAddr host_mac;
char host_macaddr[VIR_MAC_STRING_BUFLEN];
struct openvz_driver *driver = conn->privateData;
char *opt = NULL;
@@ -770,9 +770,9 @@ openvzDomainSetNetwork(virConnectPtr con
ADD_ARG_LIT(vpsid);
}
- virMacAddrFormat(net->mac, macaddr);
- virCapabilitiesGenerateMac(driver->caps, host_mac);
- virMacAddrFormat(host_mac, host_macaddr);
+ virMacAddrFormat(&net->mac, macaddr);
+ virCapabilitiesGenerateMac(driver->caps, &host_mac);
+ virMacAddrFormat(&host_mac, host_macaddr);
if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE ||
(net->type == VIR_DOMAIN_NET_TYPE_ETHERNET &&
Index: libvirt-acl/src/qemu/qemu_bridge_filter.c
===================================================================
--- libvirt-acl.orig/src/qemu/qemu_bridge_filter.c
+++ libvirt-acl/src/qemu/qemu_bridge_filter.c
@@ -66,7 +66,7 @@ networkDisableAllFrames(struct qemud_dri
int
networkAllowMacOnPort(struct qemud_driver *driver,
const char * ifname,
- const unsigned char * mac) {
+ const virMacAddrPtr mac) {
int err;
@@ -87,7 +87,7 @@ networkAllowMacOnPort(struct qemud_drive
int
networkDisallowMacOnPort(struct qemud_driver *driver,
const char * ifname,
- const unsigned char * mac) {
+ const virMacAddrPtr mac) {
int err;
Index: libvirt-acl/src/qemu/qemu_bridge_filter.h
===================================================================
--- libvirt-acl.orig/src/qemu/qemu_bridge_filter.h
+++ libvirt-acl/src/qemu/qemu_bridge_filter.h
@@ -26,10 +26,10 @@
int networkAllowMacOnPort(struct qemud_driver *driver,
const char * ifname,
- const unsigned char * mac);
+ const virMacAddrPtr mac);
int networkDisallowMacOnPort(struct qemud_driver *driver,
const char * ifname,
- const unsigned char * mac);
+ const virMacAddrPtr mac);
int networkDisableAllFrames(struct qemud_driver *driver);
int networkAddEbtablesRules(struct qemud_driver *driver);
Index: libvirt-acl/src/qemu/qemu_command.c
===================================================================
--- libvirt-acl.orig/src/qemu/qemu_command.c
+++ libvirt-acl/src/qemu/qemu_command.c
@@ -157,7 +157,7 @@ qemuPhysIfaceConnect(virDomainDefPtr def
vnet_hdr = 1;
rc = virNetDevMacVLanCreateWithVPortProfile(
- net->ifname, net->mac,
+ net->ifname, &net->mac,
virDomainNetGetActualDirectDev(net),
virDomainNetGetActualDirectMode(net),
true, vnet_hdr, def->uuid,
@@ -251,7 +251,7 @@ qemuNetworkIfaceConnect(virDomainDefPtr
tap_create_flags |= VIR_NETDEV_TAP_CREATE_VNET_HDR;
}
- err = virNetDevTapCreateInBridgePort(brname, &net->ifname, net->mac,
+ err = virNetDevTapCreateInBridgePort(brname, &net->ifname, &net->mac,
def->uuid, &tapfd,
virDomainNetGetActualVirtPortProfile(net),
tap_create_flags);
@@ -263,7 +263,7 @@ qemuNetworkIfaceConnect(virDomainDefPtr
}
if (driver->macFilter) {
- if ((err = networkAllowMacOnPort(driver, net->ifname, net->mac))) {
+ if ((err = networkAllowMacOnPort(driver, net->ifname, &net->mac))) {
virReportSystemError(err,
_("failed to add ebtables rule to allow MAC address on '%s'"),
net->ifname);
@@ -2857,9 +2857,9 @@ qemuBuildNicStr(virDomainNetDefPtr net,
if (virAsprintf(&str,
"%smacaddr=%02x:%02x:%02x:%02x:%02x:%02x,vlan=%d%s%s%s%s",
prefix ? prefix : "",
- net->mac[0], net->mac[1],
- net->mac[2], net->mac[3],
- net->mac[4], net->mac[5],
+ net->mac.addr[0], net->mac.addr[1],
+ net->mac.addr[2], net->mac.addr[3],
+ net->mac.addr[4], net->mac.addr[5],
vlan,
(net->model ? ",model=" : ""),
(net->model ? net->model : ""),
@@ -2937,9 +2937,9 @@ qemuBuildNicDevStr(virDomainNetDefPtr ne
virBufferAsprintf(&buf, ",vlan=%d", vlan);
virBufferAsprintf(&buf, ",id=%s", net->info.alias);
virBufferAsprintf(&buf, ",mac=%02x:%02x:%02x:%02x:%02x:%02x",
- net->mac[0], net->mac[1],
- net->mac[2], net->mac[3],
- net->mac[4], net->mac[5]);
+ net->mac.addr[0], net->mac.addr[1],
+ net->mac.addr[2], net->mac.addr[3],
+ net->mac.addr[4], net->mac.addr[5]);
if (qemuBuildDeviceAddressStr(&buf, &net->info, qemuCaps) < 0)
goto error;
if (qemuBuildRomStr(&buf, &net->info, qemuCaps) < 0)
@@ -7038,7 +7038,7 @@ qemuParseCommandLineNet(virCapsPtr caps,
for (i = 0 ; i < nkeywords ; i++) {
if (STREQ(keywords[i], "macaddr")) {
genmac = 0;
- if (virMacAddrParse(values[i], def->mac) < 0) {
+ if (virMacAddrParse(values[i], &def->mac) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("unable to parse mac address '%s'"),
values[i]);
@@ -7068,7 +7068,7 @@ qemuParseCommandLineNet(virCapsPtr caps,
}
if (genmac)
- virCapabilitiesGenerateMac(caps, def->mac);
+ virCapabilitiesGenerateMac(caps, &def->mac);
cleanup:
for (i = 0 ; i < nkeywords ; i++) {
Index: libvirt-acl/src/qemu/qemu_driver.c
===================================================================
--- libvirt-acl.orig/src/qemu/qemu_driver.c
+++ libvirt-acl/src/qemu/qemu_driver.c
@@ -443,7 +443,7 @@ static void qemuDomainNetsRestart(void *
VIR_DEBUG("VEPA mode device %s active in domain %s. Reassociating.",
net->ifname, def->name);
ignore_value(virNetDevMacVLanRestartWithVPortProfile(net->ifname,
- net->mac,
+ &net->mac,
virDomainNetGetActualDirectDev(net),
def->uuid,
virDomainNetGetActualVirtPortProfile(net),
@@ -5560,9 +5560,10 @@ qemuDomainAttachDeviceConfig(virDomainDe
case VIR_DOMAIN_DEVICE_NET:
net = dev->data.net;
- if (virDomainNetIndexByMac(vmdef, net->mac) >= 0) {
+ if (virDomainNetIndexByMac(vmdef, &net->mac) >= 0) {
char macbuf[VIR_MAC_STRING_BUFLEN];
- virMacAddrFormat(net->mac, macbuf);
+
+ virMacAddrFormat(&net->mac, macbuf);
qemuReportError(VIR_ERR_INVALID_ARG,
_("mac %s already exists"), macbuf);
return -1;
@@ -5638,10 +5639,10 @@ qemuDomainDetachDeviceConfig(virDomainDe
case VIR_DOMAIN_DEVICE_NET:
net = dev->data.net;
- if (!(det_net = virDomainNetRemoveByMac(vmdef, net->mac))) {
+ if (!(det_net = virDomainNetRemoveByMac(vmdef, &net->mac))) {
char macbuf[VIR_MAC_STRING_BUFLEN];
- virMacAddrFormat(net->mac, macbuf);
+ virMacAddrFormat(&net->mac, macbuf);
qemuReportError(VIR_ERR_INVALID_ARG,
_("no nic of mac %s"), macbuf);
return -1;
@@ -5729,9 +5730,10 @@ qemuDomainUpdateDeviceConfig(virDomainDe
case VIR_DOMAIN_DEVICE_NET:
net = dev->data.net;
- if ((pos = virDomainNetIndexByMac(vmdef, net->mac)) < 0) {
+ if ((pos = virDomainNetIndexByMac(vmdef, &net->mac)) < 0) {
char macbuf[VIR_MAC_STRING_BUFLEN];
- virMacAddrFormat(net->mac, macbuf);
+
+ virMacAddrFormat(&net->mac, macbuf);
qemuReportError(VIR_ERR_INVALID_ARG,
_("mac %s doesn't exist"), macbuf);
return -1;
Index: libvirt-acl/src/qemu/qemu_hostdev.c
===================================================================
--- libvirt-acl.orig/src/qemu/qemu_hostdev.c
+++ libvirt-acl/src/qemu/qemu_hostdev.c
@@ -257,7 +257,7 @@ cleanup:
static int
qemuDomainHostdevNetConfigVirtPortProfile(const char *linkdev, int vf,
virNetDevVPortProfilePtr virtPort,
- const unsigned char *macaddr,
+ const virMacAddrPtr macaddr,
const unsigned char *uuid,
int associate)
{
@@ -320,12 +320,12 @@ qemuDomainHostdevNetConfigReplace(virDom
hostdev->parent.data.net)
if (virtPort)
ret = qemuDomainHostdevNetConfigVirtPortProfile(linkdev, vf,
- virtPort, hostdev->parent.data.net->mac, uuid,
+ virtPort, &hostdev->parent.data.net->mac, uuid,
port_profile_associate);
else
/* Set only mac */
ret = virNetDevReplaceNetConfig(linkdev, vf,
- hostdev->parent.data.net->mac, vlanid,
+ &hostdev->parent.data.net->mac, vlanid,
stateDir);
VIR_FREE(linkdev);
@@ -358,7 +358,7 @@ qemuDomainHostdevNetConfigRestore(virDom
hostdev->parent.data.net)
if (virtPort)
ret = qemuDomainHostdevNetConfigVirtPortProfile(linkdev, vf, virtPort,
- hostdev->parent.data.net->mac, NULL,
+ &hostdev->parent.data.net->mac, NULL,
port_profile_associate);
else
ret = virNetDevRestoreNetConfig(linkdev, vf, stateDir);
Index: libvirt-acl/src/qemu/qemu_hotplug.c
===================================================================
--- libvirt-acl.orig/src/qemu/qemu_hotplug.c
+++ libvirt-acl/src/qemu/qemu_hotplug.c
@@ -1226,7 +1226,7 @@ static virDomainNetDefPtr qemuDomainFind
int i;
for (i = 0; i < vm->def->nnets; i++) {
- if (memcmp(vm->def->nets[i]->mac, dev->mac, VIR_MAC_BUFLEN) == 0)
+ if (virMacAddrCmp(&vm->def->nets[i]->mac, &dev->mac) == 0)
return vm->def->nets[i];
}
@@ -2190,7 +2190,7 @@ qemuDomainDetachNetDevice(struct qemud_d
for (i = 0 ; i < vm->def->nnets ; i++) {
virDomainNetDefPtr net = vm->def->nets[i];
- if (!memcmp(net->mac, dev->data.net->mac, sizeof(net->mac))) {
+ if (!virMacAddrCmp(&net->mac, &dev->data.net->mac)) {
detach = net;
break;
}
@@ -2199,9 +2199,9 @@ qemuDomainDetachNetDevice(struct qemud_d
if (!detach) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
_("network device %02x:%02x:%02x:%02x:%02x:%02x not found"),
- dev->data.net->mac[0], dev->data.net->mac[1],
- dev->data.net->mac[2], dev->data.net->mac[3],
- dev->data.net->mac[4], dev->data.net->mac[5]);
+ dev->data.net->mac.addr[0], dev->data.net->mac.addr[1],
+ dev->data.net->mac.addr[2], dev->data.net->mac.addr[3],
+ dev->data.net->mac.addr[4], dev->data.net->mac.addr[5]);
goto cleanup;
}
@@ -2280,7 +2280,7 @@ qemuDomainDetachNetDevice(struct qemud_d
if (virDomainNetGetActualType(detach) == VIR_DOMAIN_NET_TYPE_DIRECT) {
ignore_value(virNetDevMacVLanDeleteWithVPortProfile(
- detach->ifname, detach->mac,
+ detach->ifname, &detach->mac,
virDomainNetGetActualDirectDev(detach),
virDomainNetGetActualDirectMode(detach),
virDomainNetGetActualVirtPortProfile(detach),
@@ -2291,7 +2291,7 @@ qemuDomainDetachNetDevice(struct qemud_d
if ((driver->macFilter) && (detach->ifname != NULL)) {
if ((errno = networkDisallowMacOnPort(driver,
detach->ifname,
- detach->mac))) {
+ &detach->mac))) {
virReportSystemError(errno,
_("failed to remove ebtables rule on '%s'"),
detach->ifname);
Index: libvirt-acl/src/qemu/qemu_migration.c
===================================================================
--- libvirt-acl.orig/src/qemu/qemu_migration.c
+++ libvirt-acl/src/qemu/qemu_migration.c
@@ -2857,7 +2857,7 @@ qemuMigrationVPAssociatePortProfiles(vir
if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_DIRECT) {
if (virNetDevVPortProfileAssociate(net->ifname,
virDomainNetGetActualVirtPortProfile(net),
- net->mac,
+ &net->mac,
virDomainNetGetActualDirectDev(net),
-1,
def->uuid,
@@ -2870,7 +2870,7 @@ qemuMigrationVPAssociatePortProfiles(vir
}
VIR_DEBUG("Port profile Associate succeeded for %s", net->ifname);
- if (virNetDevMacVLanVPortProfileRegisterCallback(net->ifname, net->mac,
+ if (virNetDevMacVLanVPortProfileRegisterCallback(net->ifname, &net->mac,
virDomainNetGetActualDirectDev(net), def->uuid,
virDomainNetGetActualVirtPortProfile(net),
VIR_NETDEV_VPORT_PROFILE_OP_CREATE))
@@ -2887,7 +2887,7 @@ err_exit:
if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_DIRECT) {
ignore_value(virNetDevVPortProfileDisassociate(net->ifname,
virDomainNetGetActualVirtPortProfile(net),
- net->mac,
+ &net->mac,
virDomainNetGetActualDirectDev(net),
-1,
VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_FINISH));
Index: libvirt-acl/src/qemu/qemu_process.c
===================================================================
--- libvirt-acl.orig/src/qemu/qemu_process.c
+++ libvirt-acl/src/qemu/qemu_process.c
@@ -4027,7 +4027,7 @@ void qemuProcessStop(struct qemud_driver
if (net->ifname == NULL)
continue;
if ((errno = networkDisallowMacOnPort(driver, net->ifname,
- net->mac))) {
+ &net->mac))) {
virReportSystemError(errno,
_("failed to remove ebtables rule to allow MAC address on '%s'"),
net->ifname);
@@ -4100,7 +4100,7 @@ void qemuProcessStop(struct qemud_driver
virDomainNetDefPtr net = def->nets[i];
if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_DIRECT) {
ignore_value(virNetDevMacVLanDeleteWithVPortProfile(
- net->ifname, net->mac,
+ net->ifname, &net->mac,
virDomainNetGetActualDirectDev(net),
virDomainNetGetActualDirectMode(net),
virDomainNetGetActualVirtPortProfile(net),
Index: libvirt-acl/src/uml/uml_conf.c
===================================================================
--- libvirt-acl.orig/src/uml/uml_conf.c
+++ libvirt-acl/src/uml/uml_conf.c
@@ -138,7 +138,7 @@ umlConnectTapDevice(virConnectPtr conn,
template_ifname = true;
}
- if (virNetDevTapCreateInBridgePort(bridge, &net->ifname, net->mac,
+ if (virNetDevTapCreateInBridgePort(bridge, &net->ifname, &net->mac,
vm->uuid, NULL,
virDomainNetGetActualVirtPortProfile(net),
VIR_NETDEV_TAP_CREATE_IFUP) < 0) {
@@ -271,8 +271,8 @@ umlBuildCommandLineNet(virConnectPtr con
}
virBufferAsprintf(&buf, ",%02x:%02x:%02x:%02x:%02x:%02x",
- def->mac[0], def->mac[1], def->mac[2],
- def->mac[3], def->mac[4], def->mac[5]);
+ def->mac.addr[0], def->mac.addr[1], def->mac.addr[2],
+ def->mac.addr[3], def->mac.addr[4], def->mac.addr[5]);
if (def->type == VIR_DOMAIN_NET_TYPE_MCAST) {
virBufferAsprintf(&buf, ",%s,%d",
Index: libvirt-acl/src/util/ebtables.c
===================================================================
--- libvirt-acl.orig/src/util/ebtables.c
+++ libvirt-acl/src/util/ebtables.c
@@ -392,15 +392,15 @@ ebtablesForwardAllowIn(ebtablesContext *
int
ebtablesAddForwardAllowIn(ebtablesContext *ctx,
const char *iface,
- const unsigned char *mac)
+ const virMacAddrPtr mac)
{
char *macaddr;
if (virAsprintf(&macaddr,
"%02x:%02x:%02x:%02x:%02x:%02x",
- mac[0], mac[1],
- mac[2], mac[3],
- mac[4], mac[5]) < 0) {
+ mac->addr[0], mac->addr[1],
+ mac->addr[2], mac->addr[3],
+ mac->addr[4], mac->addr[5]) < 0) {
return -1;
}
return ebtablesForwardAllowIn(ctx, iface, macaddr, ADD);
@@ -421,15 +421,15 @@ ebtablesAddForwardAllowIn(ebtablesContex
int
ebtablesRemoveForwardAllowIn(ebtablesContext *ctx,
const char *iface,
- const unsigned char *mac)
+ const virMacAddrPtr mac)
{
char *macaddr;
if (virAsprintf(&macaddr,
"%02x:%02x:%02x:%02x:%02x:%02x",
- mac[0], mac[1],
- mac[2], mac[3],
- mac[4], mac[5]) < 0) {
+ mac->addr[0], mac->addr[1],
+ mac->addr[2], mac->addr[3],
+ mac->addr[4], mac->addr[5]) < 0) {
return -1;
}
return ebtablesForwardAllowIn(ctx, iface, macaddr, REMOVE);
Index: libvirt-acl/src/util/ebtables.h
===================================================================
--- libvirt-acl.orig/src/util/ebtables.h
+++ libvirt-acl/src/util/ebtables.h
@@ -24,6 +24,8 @@
#ifndef __QEMUD_EBTABLES_H__
# define __QEMUD_EBTABLES_H__
+# include "virmacaddr.h"
+
typedef struct
{
char *rule;
@@ -50,10 +52,10 @@ void ebtablesSaveRules
int ebtablesAddForwardAllowIn (ebtablesContext *ctx,
const char *iface,
- const unsigned char *mac);
+ const virMacAddrPtr mac);
int ebtablesRemoveForwardAllowIn (ebtablesContext *ctx,
const char *iface,
- const unsigned char *mac);
+ const virMacAddrPtr mac);
int ebtablesAddForwardPolicyReject(ebtablesContext *ctx);
Index: libvirt-acl/src/util/virnetdevopenvswitch.c
===================================================================
--- libvirt-acl.orig/src/util/virnetdevopenvswitch.c
+++ libvirt-acl/src/util/virnetdevopenvswitch.c
@@ -44,7 +44,7 @@
* Returns 0 in case of success or -1 in case of failure.
*/
int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname,
- const unsigned char *macaddr,
+ const virMacAddrPtr macaddr,
const unsigned char *vmuuid,
virNetDevVPortProfilePtr ovsport)
{
Index: libvirt-acl/src/util/virnetdevopenvswitch.h
===================================================================
--- libvirt-acl.orig/src/util/virnetdevopenvswitch.h
+++ libvirt-acl/src/util/virnetdevopenvswitch.h
@@ -31,7 +31,7 @@
int virNetDevOpenvswitchAddPort(const char *brname,
const char *ifname,
- const unsigned char *macaddr,
+ const virMacAddrPtr macaddr,
const unsigned char *vmuuid,
virNetDevVPortProfilePtr ovsport)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
Index: libvirt-acl/src/util/virnetdevtap.c
===================================================================
--- libvirt-acl.orig/src/util/virnetdevtap.c
+++ libvirt-acl/src/util/virnetdevtap.c
@@ -256,7 +256,7 @@ int virNetDevTapDelete(const char *ifnam
* virNetDevTapCreateInBridgePort:
* @brname: the bridge name
* @ifname: the interface name (or name template)
- * @macaddr: desired MAC address (VIR_MAC_BUFLEN long)
+ * @macaddr: desired MAC address
* @tapfd: file descriptor return value for the new tap device
* @virtPortProfile: bridge/port specific configuration
* @flags: OR of virNetDevTapCreateFlags:
@@ -280,13 +280,13 @@ int virNetDevTapDelete(const char *ifnam
*/
int virNetDevTapCreateInBridgePort(const char *brname,
char **ifname,
- const unsigned char *macaddr,
+ const virMacAddrPtr macaddr,
const unsigned char *vmuuid,
int *tapfd,
virNetDevVPortProfilePtr virtPortProfile,
unsigned int flags)
{
- unsigned char tapmac[VIR_MAC_BUFLEN];
+ virMacAddr tapmac;
if (virNetDevTapCreate(ifname, tapfd, flags) < 0)
return -1;
@@ -297,9 +297,9 @@ int virNetDevTapCreateInBridgePort(const
* seeing the kernel allocate random MAC for the TAP
* device before we set our static MAC.
*/
- memcpy(tapmac, macaddr, VIR_MAC_BUFLEN);
+ virMacAddrSet(&tapmac, macaddr);
if (!(flags & VIR_NETDEV_TAP_CREATE_USE_MAC_FOR_BRIDGE)) {
- if (macaddr[0] == 0xFE) {
+ if (macaddr->addr[0] == 0xFE) {
/* For normal use, the tap device's MAC address cannot
* match the MAC address used by the guest. This results
* in "received packet on vnetX with own address as source
@@ -308,14 +308,15 @@ int virNetDevTapCreateInBridgePort(const
virNetDevTapError(VIR_ERR_CONFIG_UNSUPPORTED,
"Unable to use MAC address starting with "
"reserved value 0xFE - '%02X:%02X:%02X:%02X:%02X:%02X' - ",
- macaddr[0], macaddr[1], macaddr[2],
- macaddr[3], macaddr[4], macaddr[5]);
+ macaddr->addr[0], macaddr->addr[1],
+ macaddr->addr[2], macaddr->addr[3],
+ macaddr->addr[4], macaddr->addr[5]);
goto error;
}
- tapmac[0] = 0xFE; /* Discourage bridge from using TAP dev MAC */
+ tapmac.addr[0] = 0xFE; /* Discourage bridge from using TAP dev MAC */
}
- if (virNetDevSetMAC(*ifname, tapmac) < 0)
+ if (virNetDevSetMAC(*ifname, &tapmac) < 0)
goto error;
/* We need to set the interface MTU before adding it
Index: libvirt-acl/src/util/virnetdevtap.h
===================================================================
--- libvirt-acl.orig/src/util/virnetdevtap.h
+++ libvirt-acl/src/util/virnetdevtap.h
@@ -46,7 +46,7 @@ typedef enum {
int virNetDevTapCreateInBridgePort(const char *brname,
char **ifname,
- const unsigned char *macaddr,
+ const virMacAddrPtr macaddr,
const unsigned char *vmuuid,
int *tapfd,
virNetDevVPortProfilePtr virtPortProfile,
Index: libvirt-acl/src/util/virnetdevvportprofile.c
===================================================================
--- libvirt-acl.orig/src/util/virnetdevvportprofile.c
+++ libvirt-acl/src/util/virnetdevvportprofile.c
@@ -264,7 +264,7 @@ cleanup:
static int
virNetDevVPortProfileOpSetLink(const char *ifname, int ifindex,
bool nltarget_kernel,
- const unsigned char *macaddr,
+ const virMacAddrPtr macaddr,
int vlanid,
const char *profileId,
struct ifla_port_vsi *portVsi,
@@ -315,7 +315,7 @@ virNetDevVPortProfileOpSetLink(const cha
.mac = { 0, },
};
- memcpy(ifla_vf_mac.mac, macaddr, 6);
+ virMacAddrGetRaw(macaddr, ifla_vf_mac.mac);
if (nla_put(nl_msg, IFLA_VF_MAC, sizeof(ifla_vf_mac),
&ifla_vf_mac) < 0)
@@ -515,7 +515,7 @@ virNetDevVPortProfileGetNthParent(const
static int
virNetDevVPortProfileOpCommon(const char *ifname, int ifindex,
bool nltarget_kernel,
- const unsigned char *macaddr,
+ const virMacAddrPtr macaddr,
int vlanid,
const char *profileId,
struct ifla_port_vsi *portVsi,
@@ -633,7 +633,7 @@ virNetDevVPortProfileGetPhysdevAndVlan(c
/* Returns 0 on success, -1 on general failure, and -2 on timeout */
static int
virNetDevVPortProfileOp8021Qbg(const char *ifname,
- const unsigned char *macaddr,
+ const virMacAddrPtr macaddr,
int vf,
const virNetDevVPortProfilePtr virtPort,
enum virNetDevVPortProfileLinkOp virtPortOp,
@@ -701,7 +701,7 @@ cleanup:
/* Returns 0 on success, -1 on general failure, and -2 on timeout */
static int
virNetDevVPortProfileOp8021Qbh(const char *ifname,
- const unsigned char *macaddr,
+ const virMacAddrPtr macaddr,
int32_t vf,
const virNetDevVPortProfilePtr virtPort,
const unsigned char *vm_uuid,
@@ -825,7 +825,7 @@ cleanup:
int
virNetDevVPortProfileAssociate(const char *macvtap_ifname,
const virNetDevVPortProfilePtr virtPort,
- const unsigned char *macvtap_macaddr,
+ const virMacAddrPtr macvtap_macaddr,
const char *linkdev,
int vf,
const unsigned char *vmuuid,
@@ -889,7 +889,7 @@ virNetDevVPortProfileAssociate(const cha
int
virNetDevVPortProfileDisassociate(const char *macvtap_ifname,
const virNetDevVPortProfilePtr virtPort,
- const unsigned char *macvtap_macaddr,
+ const virMacAddrPtr macvtap_macaddr,
const char *linkdev,
int vf,
enum virNetDevVPortProfileOp vmOp)
@@ -933,7 +933,7 @@ virNetDevVPortProfileDisassociate(const
#else /* ! WITH_VIRTUALPORT */
int virNetDevVPortProfileAssociate(const char *macvtap_ifname ATTRIBUTE_UNUSED,
const virNetDevVPortProfilePtr virtPort ATTRIBUTE_UNUSED,
- const unsigned char *macvtap_macaddr ATTRIBUTE_UNUSED,
+ const virMacAddrPtr macvtap_macaddr ATTRIBUTE_UNUSED,
const char *linkdev ATTRIBUTE_UNUSED,
int vf ATTRIBUTE_UNUSED,
const unsigned char *vmuuid ATTRIBUTE_UNUSED,
@@ -947,7 +947,7 @@ int virNetDevVPortProfileAssociate(const
int virNetDevVPortProfileDisassociate(const char *macvtap_ifname ATTRIBUTE_UNUSED,
const virNetDevVPortProfilePtr virtPort ATTRIBUTE_UNUSED,
- const unsigned char *macvtap_macaddr ATTRIBUTE_UNUSED,
+ const virMacAddrPtr macvtap_macaddr ATTRIBUTE_UNUSED,
const char *linkdev ATTRIBUTE_UNUSED,
int vf ATTRIBUTE_UNUSED,
enum virNetDevVPortProfileOp vmOp ATTRIBUTE_UNUSED)
Index: libvirt-acl/src/vbox/vbox_tmpl.c
===================================================================
--- libvirt-acl.orig/src/vbox/vbox_tmpl.c
+++ libvirt-acl/src/vbox/vbox_tmpl.c
@@ -3038,7 +3038,7 @@ sharedFoldersCleanup:
MACAddress[8], MACAddress[9], MACAddress[10], MACAddress[11]);
/* XXX some real error handling here some day ... */
- if (virMacAddrParse(macaddr, def->nets[netAdpIncCnt]->mac) < 0)
+ if (virMacAddrParse(macaddr, &def->nets[netAdpIncCnt]->mac) < 0)
{}
netAdpIncCnt++;
@@ -4387,15 +4387,15 @@ vboxAttachNetwork(virDomainDefPtr def, v
char macaddr[VIR_MAC_STRING_BUFLEN] = {0};
char macaddrvbox[VIR_MAC_STRING_BUFLEN - 5] = {0};
- virMacAddrFormat(def->nets[i]->mac, macaddr);
+ virMacAddrFormat(&def->nets[i]->mac, macaddr);
snprintf(macaddrvbox, VIR_MAC_STRING_BUFLEN - 5,
"%02X%02X%02X%02X%02X%02X",
- def->nets[i]->mac[0],
- def->nets[i]->mac[1],
- def->nets[i]->mac[2],
- def->nets[i]->mac[3],
- def->nets[i]->mac[4],
- def->nets[i]->mac[5]);
+ def->nets[i]->mac.addr[0],
+ def->nets[i]->mac.addr[1],
+ def->nets[i]->mac.addr[2],
+ def->nets[i]->mac.addr[3],
+ def->nets[i]->mac.addr[4],
+ def->nets[i]->mac.addr[5]);
macaddrvbox[VIR_MAC_STRING_BUFLEN - 6] = '\0';
VIR_DEBUG("NIC(%d): Type: %d", i, def->nets[i]->type);
Index: libvirt-acl/src/vmx/vmx.c
===================================================================
--- libvirt-acl.orig/src/vmx/vmx.c
+++ libvirt-acl/src/vmx/vmx.c
@@ -2365,7 +2365,7 @@ virVMXParseEthernet(virConfPtr conf, int
if (addressType == NULL || STRCASEEQ(addressType, "generated") ||
STRCASEEQ(addressType, "vpx")) {
if (generatedAddress != NULL) {
- if (virMacAddrParse(generatedAddress, (*def)->mac) < 0) {
+ if (virMacAddrParse(generatedAddress, &(*def)->mac) < 0) {
VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry '%s' to be MAC address but "
"found '%s'"), generatedAddress_name,
@@ -2375,7 +2375,7 @@ virVMXParseEthernet(virConfPtr conf, int
}
} else if (STRCASEEQ(addressType, "static")) {
if (address != NULL) {
- if (virMacAddrParse(address, (*def)->mac) < 0) {
+ if (virMacAddrParse(address, &(*def)->mac) < 0) {
VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry '%s' to be MAC address but "
"found '%s'"), address_name, address);
@@ -3567,10 +3567,10 @@ virVMXFormatEthernet(virDomainNetDefPtr
}
/* def:mac -> vmx:addressType, vmx:(generated)Address, vmx:checkMACAddress */
- virMacAddrFormat(def->mac, mac_string);
+ virMacAddrFormat(&def->mac, mac_string);
- prefix = (def->mac[0] << 16) | (def->mac[1] << 8) | def->mac[2];
- suffix = (def->mac[3] << 16) | (def->mac[4] << 8) | def->mac[5];
+ prefix = (def->mac.addr[0] << 16) | (def->mac.addr[1] << 8) | def->mac.addr[2];
+ suffix = (def->mac.addr[3] << 16) | (def->mac.addr[4] << 8) | def->mac.addr[5];
if (prefix == 0x000c29) {
virBufferAsprintf(buffer, "ethernet%d.addressType = \"generated\"\n",
Index: libvirt-acl/src/xen/xend_internal.c
===================================================================
--- libvirt-acl.orig/src/xen/xend_internal.c
+++ libvirt-acl/src/xen/xend_internal.c
@@ -2718,7 +2718,7 @@ xenDaemonAttachDeviceFlags(virDomainPtr
goto cleanup;
char macStr[VIR_MAC_STRING_BUFLEN];
- virMacAddrFormat(dev->data.net->mac, macStr);
+ virMacAddrFormat(&dev->data.net->mac, macStr);
if (!(target = strdup(macStr))) {
virReportOOMError();
@@ -3955,8 +3955,8 @@ virDomainXMLDevID(virDomainPtr domain,
char mac[30];
virDomainNetDefPtr def = dev->data.net;
snprintf(mac, sizeof(mac), "%02x:%02x:%02x:%02x:%02x:%02x",
- def->mac[0], def->mac[1], def->mac[2],
- def->mac[3], def->mac[4], def->mac[5]);
+ def->mac.addr[0], def->mac.addr[1], def->mac.addr[2],
+ def->mac.addr[3], def->mac.addr[4], def->mac.addr[5]);
strcpy(class, "vif");
Index: libvirt-acl/src/xen/xm_internal.c
===================================================================
--- libvirt-acl.orig/src/xen/xm_internal.c
+++ libvirt-acl/src/xen/xm_internal.c
@@ -1533,9 +1533,7 @@ xenXMDomainDetachDeviceFlags(virDomainPt
case VIR_DOMAIN_DEVICE_NET:
{
for (i = 0 ; i < def->nnets ; i++) {
- if (!memcmp(def->nets[i]->mac,
- dev->data.net->mac,
- sizeof(def->nets[i]->mac))) {
+ if (!virMacAddrCmp(&def->nets[i]->mac, &dev->data.net->mac)) {
virDomainNetDefFree(def->nets[i]);
if (i < (def->nnets - 1))
memmove(def->nets + i,
Index: libvirt-acl/src/xenxs/xen_sxpr.c
===================================================================
--- libvirt-acl.orig/src/xenxs/xen_sxpr.c
+++ libvirt-acl/src/xenxs/xen_sxpr.c
@@ -600,7 +600,7 @@ xenParseSxprNets(virDomainDefPtr def,
tmp = sexpr_node(node, "device/vif/mac");
if (tmp) {
- if (virMacAddrParse(tmp, net->mac) < 0) {
+ if (virMacAddrParse(tmp, &net->mac) < 0) {
XENXS_ERROR(VIR_ERR_INTERNAL_ERROR,
_("malformed mac address '%s'"), tmp);
goto cleanup;
@@ -1932,8 +1932,8 @@ xenFormatSxprNet(virConnectPtr conn,
virBufferAsprintf(buf,
"(mac '%02x:%02x:%02x:%02x:%02x:%02x')",
- def->mac[0], def->mac[1], def->mac[2],
- def->mac[3], def->mac[4], def->mac[5]);
+ def->mac.addr[0], def->mac.addr[1], def->mac.addr[2],
+ def->mac.addr[3], def->mac.addr[4], def->mac.addr[5]);
switch (def->type) {
case VIR_DOMAIN_NET_TYPE_BRIDGE:
Index: libvirt-acl/src/xenxs/xen_xm.c
===================================================================
--- libvirt-acl.orig/src/xenxs/xen_xm.c
+++ libvirt-acl/src/xenxs/xen_xm.c
@@ -742,7 +742,7 @@ xenParseXM(virConfPtr conf, int xendConf
goto no_memory;
if (mac[0]) {
- if (virMacAddrParse(mac, net->mac) < 0) {
+ if (virMacAddrParse(mac, &net->mac) < 0) {
XENXS_ERROR(VIR_ERR_INTERNAL_ERROR,
_("malformed mac address '%s'"), mac);
goto cleanup;
@@ -1326,9 +1326,9 @@ static int xenFormatXMNet(virConnectPtr
virConfValuePtr val, tmp;
virBufferAsprintf(&buf, "mac=%02x:%02x:%02x:%02x:%02x:%02x",
- net->mac[0], net->mac[1],
- net->mac[2], net->mac[3],
- net->mac[4], net->mac[5]);
+ net->mac.addr[0], net->mac.addr[1],
+ net->mac.addr[2], net->mac.addr[3],
+ net->mac.addr[4], net->mac.addr[5]);
switch (net->type) {
case VIR_DOMAIN_NET_TYPE_BRIDGE:
Index: libvirt-acl/tools/virsh.c
===================================================================
--- libvirt-acl.orig/tools/virsh.c
+++ libvirt-acl/tools/virsh.c
@@ -1935,7 +1935,7 @@ cmdDomIfSetLink(vshControl *ctl, const v
const char *state;
const char *value;
const char *desc;
- unsigned char macaddr[VIR_MAC_BUFLEN];
+ virMacAddr macaddr;
const char *element;
const char *attr;
bool config;
@@ -1997,7 +1997,7 @@ cmdDomIfSetLink(vshControl *ctl, const v
goto cleanup;
}
- if (virMacAddrParse(iface, macaddr) == 0) {
+ if (virMacAddrParse(iface, &macaddr) == 0) {
element = "mac";
attr = "address";
} else {
@@ -2111,7 +2111,7 @@ cmdDomIfGetLink(vshControl *ctl, const v
int flags = 0;
char *state = NULL;
char *value = NULL;
- unsigned char macaddr[VIR_MAC_BUFLEN];
+ virMacAddr macaddr;
const char *element;
const char *attr;
bool ret = false;
@@ -2156,7 +2156,7 @@ cmdDomIfGetLink(vshControl *ctl, const v
goto cleanup;
}
- if (virMacAddrParse(iface, macaddr) == 0) {
+ if (virMacAddrParse(iface, &macaddr) == 0) {
element = "mac";
attr = "address";
} else {
Index: libvirt-acl/src/lxc/lxc_driver.c
===================================================================
--- libvirt-acl.orig/src/lxc/lxc_driver.c
+++ libvirt-acl/src/lxc/lxc_driver.c
@@ -1202,11 +1202,11 @@ static int lxcSetupInterfaceBridged(virC
(*veths)[(*nveths)] = containerVeth;
(*nveths)++;
- if (virNetDevSetMAC(containerVeth, net->mac) < 0)
+ if (virNetDevSetMAC(containerVeth, &net->mac) < 0)
goto cleanup;
if (vport && vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH)
- ret = virNetDevOpenvswitchAddPort(brname, parentVeth, net->mac,
+ ret = virNetDevOpenvswitchAddPort(brname, parentVeth, &net->mac,
vm->uuid, vport);
else
ret = virNetDevBridgeAddPort(brname, parentVeth);
@@ -1280,7 +1280,7 @@ static int lxcSetupInterfaceDirect(virCo
(*veths)[(*nveths)] = NULL;
if (virNetDevMacVLanCreateWithVPortProfile(
- net->ifname, net->mac,
+ net->ifname, &net->mac,
virDomainNetGetActualDirectDev(net),
virDomainNetGetActualDirectMode(net),
false, false, def->uuid,
Index: libvirt-acl/src/libvirt_private.syms
===================================================================
--- libvirt-acl.orig/src/libvirt_private.syms
+++ libvirt-acl/src/libvirt_private.syms
@@ -1277,12 +1277,17 @@ virKeyFileGetValueString;
# virmacaddr.h
+virMacAddrCmp;
+virMacAddrCmpRaw;
virMacAddrCompare;
virMacAddrFormat;
virMacAddrGenerate;
+virMacAddrGetRaw;
virMacAddrIsMulticast;
virMacAddrIsUnicast;
virMacAddrParse;
+virMacAddrSet;
+virMacAddrSetRaw;
# virnetclient.h
Index: libvirt-acl/src/libxl/libxl_conf.c
===================================================================
--- libvirt-acl.orig/src/libxl/libxl_conf.c
+++ libvirt-acl/src/libxl/libxl_conf.c
@@ -596,7 +596,7 @@ libxlMakeNic(virDomainDefPtr def, virDom
//x_nics[i].mtu = 1492;
x_nic->domid = def->id;
- memcpy(x_nic->mac, l_nic->mac, sizeof(libxl_mac));
+ virMacAddrGetRaw(&l_nic->mac, x_nic->mac);
if (l_nic->model && !STREQ(l_nic->model, "netfront")) {
if ((x_nic->model = strdup(l_nic->model)) == NULL) {
Index: libvirt-acl/src/nwfilter/nwfilter_dhcpsnoop.h
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_dhcpsnoop.h
+++ libvirt-acl/src/nwfilter/nwfilter_dhcpsnoop.h
@@ -31,7 +31,7 @@ int virNWFilterDHCPSnoopReq(virNWFilterT
const char *linkdev,
enum virDomainNetType nettype,
const unsigned char *vmuuid,
- const unsigned char *macaddr,
+ const virMacAddrPtr macaddr,
const char *filtername,
virNWFilterHashTablePtr filterparams,
virNWFilterDriverStatePtr driver);
2
2
17 Jul '12
In trying to build libvirt 0.9.13 on F17, I'm hitting a link error:
...
CCLD libvirt_driver_nodedev.la
CCLD libvirt_driver_nwfilter.la
/usr/bin/ld: cannot find -lcrypto
Full log here:
http://kojipkgs.fedoraproject.org//work/tasks/3678/4233678/build.log
I think this comes from rbd support, from configure.ac:
LIBRBD_LIBS="-lrbd -lrados -lcrypto"
from this commit:
http://libvirt.org/git/?p=libvirt.git;a=commit;h=74951eadef85e2d100c7dc7bd9…
What's missing here? RPM BuildRequires, configure change, ...?
Thanks,
Cole
4
6
16 Jul '12
Hi All,
I am trying to extend “iscsi” support for iSCSI driver, currently am stuck at getting iSCSI target list from the hypervisor. I am using hostSystem object (propertyNameList is set to “config.storageDevice.hostBusAdapter”) to retrieve list of “HostHostBusAdapter” from ESX, but the call fails to perform “CastFromAnyType” from ObjectContent –> HostHostBusAdapter. The esx_vi_generator.input object definition looks like this:
object HostHostBusAdapter
String key o
String device r
Int bus r
String status r
String model r
String driver o
String pci o
end
esx_vi_generaor.py is modified as follows:
"HostHostBusAdapter" : Object.FEATURE__ANY_TYPE |
Object.FEATURE__LIST,
Using gdb, I see the failure occurs at: esx/esx_vi.c:esxVI_List_CastFromAnyType(..) line 1631:
..
if (esxVI_AnyType_Deserialize(childNode, &childAnyType) < 0 ||
castFromAnyTypeFunc(childAnyType, &item) < 0 ||
esxVI_List_Append(list, item) < 0) {
goto cleanup;
}
..
In one of my earlier patches (subject: Add routines to interface driver) I patched esx_vi_generator.py to deserialize “string list”; as the patch is still under review I manually applied the branch to this branch but no change (did not expect change as structure does not contain any list object). I am wondering what else is missing to make it work.
Any suggestion how to debug/fix this issue is highly appreciated.
Thanks!
Ata
1
0