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
- 19 participants
- 40177 discussions
As pointed out in https://bugzilla.redhat.com/show_bug.cgi?id=659855#c9,
commit c3568ec2 introduced a regression where we no longer close any
fd's beyond FD_SETSIZE.
* src/util/util.c (__virExec): Continue to close fd's beyond
keepfd range.
Reported by Stefan Praszalowicz.
---
src/util/util.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/util/util.c b/src/util/util.c
index d6fa81b..197c571 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -570,7 +570,7 @@ __virExec(const char *const*argv,
i != null &&
i != childout &&
i != childerr &&
- (!keepfd || (i < FD_SETSIZE && !FD_ISSET(i, keepfd)))) {
+ (!keepfd || i >= FD_SETSIZE || !FD_ISSET(i, keepfd))) {
tmpfd = i;
VIR_FORCE_CLOSE(tmpfd);
}
--
1.7.3.4
2
3
The first two patches remedy a bug found by Stefan Berger in the new
brAddInetInterface() function that resulted in the broadcast address
not being properly set. This is a regression from previous releases,
so it should be pushed prior to the upcoming release.
The third patch improves the API for a couple of functions that were
recently added, but does not change any behavior. I'd be happy pushing
it now or after the release.
2
9
[libvirt] [PATCHv2 00/13] IPv6 support for virtual networks using bridge driver
by Laine Stump 31 Dec '10
by Laine Stump 31 Dec '10
31 Dec '10
This is a resend of
https://www.redhat.com/archives/libvir-list/2010-December/msg00765.html
incorporating changes due to comments from Eric Blake and Paweł Krześniak.
changes from v1 to v2 are noted in each individual mail
-----
Most of this patchset is setup for patch 09/13, which updates the
network XML parser to support IPv6, and 12/13, which turns on IPv6 in
the bridge driver.
In order to have each patch individually pass make check and
(otherwise function properly in case someone is doing a bisect), there
is a bit of extra code churn (lines that are changed in one patch,
only to be changed again in a later patch); I tried to minimize this
as much as possible.
For for IPv6 to work correctly, target *and build* systems will
now need to have ip6tables and radvd available. The way I added
ip6tables into autoconfigure.ac is identical to existing iptables, and
the way I added radvd is identical to dnsmasq. Unfortunately this
doesn't communicate the requirement downstream in a programmatic
fashion, so I guess we need to make sure that this is adequately
reported in the next set of release notes.
4
39
subscribe
--
Stefan Majer
1
0
Right now, we create qemu snapshots to a file by using an exec: monitor
command that passes 'compressor | { dd && dd; }' with stdout connected
to the target file. However, since dd is using a larger bs= than
PIPE_MAX, it is conceivable that under heavy machine load, that dd will
get a short read from the pipe, and unless we use the GNU extension of
iflag=fullblock, that short read will be padded out to the output block
size and result in data corruption in the destination file.
The possibility of corruption due to short reads when dd is fed input
through a pipe but produces output through a large block size has
occurred several times on the coreutils mailing list:
http://lists.gnu.org/archive/html/bug-coreutils/2010-11/msg00092.html
Coreutils currently obeys the (non-intuitive) POSIX requirements for
this short read behavior, and while it is being considered to make dd
when POSIXLY_CORRECT is unset be more sensible, you can't rely on that
being a default.
Should we refuse to make snapshots if we don't detect the GNU extension
of 'dd iflag=fullblock'? Probably safe to do on GNU/Linux machines, but
I'm wondering if it will have negative effects on BSD machines where GNU
coreutils is not installed.
Is there a way to make monitor commands use fd: style migration, where
we can avoid dd altogether by just passing an already open fd that has
already positioned correctly via lseek()? Then again, it seems like fd:
migration requires passing an open fd, which only seems possible on the
command line at startup rather than something you can do on the fly with
monitor commands.
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
3
5
Hi,
we use libvirt-java in our kvm based virtualization infrastructure a
lot. Thanks therefor. Sometimes we see crashes of the libvirtd and i
was thinking of the right way to handle such a situation from the java
side.
My first aproach was to use the ErrorCallback:
Connect.setErrorCallback(new VirErrorCallback() {
@Override
public void errorCallback(Pointer arg0, virError error) {
// Do something usefull (reconnect for example)
}
}
);
} catch (LibvirtException e) {
LOG.error("Exception occurred. Stacktrace: ", e);
}
}
But this give me a jvm crash on shutdown of my application. No Idea why.
The next idea was to Intercept all calls to org.libvirt.Connect and
check if the connection is still working (isConnected) and reconnect
on false.
But the current API design makes this difficult and ugly, as Connect
is a concrete Class without an Interface.
Do you have any other Ideas ?
If no, do you probably accept patches which will resolve this issue ?
We can share Ideas what the best strategie could be.
Greetings
--
Stefan Majer
1
0
Also include some whitespace changes. No functional change included.
---
I pushed this one under the trivial rule.
Matthias
src/esx/esx_driver.c | 10 ++++++++++
src/esx/esx_vi.c | 25 ++++++++++++++-----------
src/esx/esx_vi.h | 8 ++++----
3 files changed, 28 insertions(+), 15 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 55847bc..2241532 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -2475,6 +2475,7 @@ esxDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
}
+
static int
esxDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
{
@@ -2482,6 +2483,7 @@ esxDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
}
+
static int
esxDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
{
@@ -2540,6 +2542,8 @@ esxDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
return priv->maxVcpus;
}
+
+
static int
esxDomainGetMaxVcpus(virDomainPtr domain)
{
@@ -2547,6 +2551,8 @@ esxDomainGetMaxVcpus(virDomainPtr domain)
VIR_DOMAIN_VCPU_MAXIMUM));
}
+
+
static char *
esxDomainDumpXML(virDomainPtr domain, int flags)
{
@@ -3809,12 +3815,16 @@ esxDomainIsPersistent(virDomainPtr domain ATTRIBUTE_UNUSED)
return 1;
}
+
+
static int
esxDomainIsUpdated(virDomainPtr domain ATTRIBUTE_UNUSED)
{
return 0;
}
+
+
static virDomainSnapshotPtr
esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc,
unsigned int flags)
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 76be5a4..5dbf744 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -1812,7 +1812,7 @@ esxVI_GetVirtualMachineQuestionInfo
int
esxVI_GetBoolean(esxVI_ObjectContent *objectContent, const char *propertyName,
- esxVI_Boolean *value, esxVI_Occurrence occurence)
+ esxVI_Boolean *value, esxVI_Occurrence occurrence)
{
esxVI_DynamicProperty *dynamicProperty;
@@ -1835,7 +1835,7 @@ esxVI_GetBoolean(esxVI_ObjectContent *objectContent, const char *propertyName,
}
if (*value == esxVI_Boolean_Undefined &&
- occurence == esxVI_Occurrence_RequiredItem) {
+ occurrence == esxVI_Occurrence_RequiredItem) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Missing '%s' property"), propertyName);
return -1;
@@ -1844,9 +1844,11 @@ esxVI_GetBoolean(esxVI_ObjectContent *objectContent, const char *propertyName,
return 0;
}
+
+
int
esxVI_GetLong(esxVI_ObjectContent *objectContent, const char *propertyName,
- esxVI_Long **value, esxVI_Occurrence occurence)
+ esxVI_Long **value, esxVI_Occurrence occurrence)
{
esxVI_DynamicProperty *dynamicProperty;
@@ -1866,7 +1868,7 @@ esxVI_GetLong(esxVI_ObjectContent *objectContent, const char *propertyName,
}
}
- if (*value == NULL && occurence == esxVI_Occurrence_RequiredItem) {
+ if (*value == NULL && occurrence == esxVI_Occurrence_RequiredItem) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Missing '%s' property"), propertyName);
return -1;
@@ -1880,7 +1882,7 @@ esxVI_GetLong(esxVI_ObjectContent *objectContent, const char *propertyName,
int
esxVI_GetStringValue(esxVI_ObjectContent *objectContent,
const char *propertyName,
- char **value, esxVI_Occurrence occurence)
+ char **value, esxVI_Occurrence occurrence)
{
esxVI_DynamicProperty *dynamicProperty;
@@ -1902,7 +1904,7 @@ esxVI_GetStringValue(esxVI_ObjectContent *objectContent,
}
}
- if (*value == NULL && occurence == esxVI_Occurrence_RequiredItem) {
+ if (*value == NULL && occurrence == esxVI_Occurrence_RequiredItem) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Missing '%s' property"), propertyName);
return -1;
@@ -1917,7 +1919,7 @@ int
esxVI_GetManagedObjectReference(esxVI_ObjectContent *objectContent,
const char *propertyName,
esxVI_ManagedObjectReference **value,
- esxVI_Occurrence occurence)
+ esxVI_Occurrence occurrence)
{
esxVI_DynamicProperty *dynamicProperty;
@@ -1938,7 +1940,7 @@ esxVI_GetManagedObjectReference(esxVI_ObjectContent *objectContent,
}
}
- if (*value == NULL && occurence == esxVI_Occurrence_RequiredItem) {
+ if (*value == NULL && occurrence == esxVI_Occurrence_RequiredItem) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Missing '%s' property"), propertyName);
return -1;
@@ -2265,9 +2267,10 @@ esxVI_GetSnapshotTreeBySnapshot
-int esxVI_LookupHostSystemProperties(esxVI_Context *ctx,
- esxVI_String *propertyNameList,
- esxVI_ObjectContent **hostSystem)
+int
+esxVI_LookupHostSystemProperties(esxVI_Context *ctx,
+ esxVI_String *propertyNameList,
+ esxVI_ObjectContent **hostSystem)
{
return esxVI_LookupObjectContentByType(ctx, ctx->hostSystem->_reference,
"HostSystem", propertyNameList,
diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h
index d512add..553967b 100644
--- a/src/esx/esx_vi.h
+++ b/src/esx/esx_vi.h
@@ -300,19 +300,19 @@ int esxVI_GetVirtualMachineQuestionInfo
int esxVI_GetBoolean(esxVI_ObjectContent *objectContent,
const char *propertyName,
- esxVI_Boolean *value, esxVI_Occurrence occurence);
+ esxVI_Boolean *value, esxVI_Occurrence occurrence);
int esxVI_GetLong(esxVI_ObjectContent *objectContent, const char *propertyName,
- esxVI_Long **value, esxVI_Occurrence occurence);
+ esxVI_Long **value, esxVI_Occurrence occurrence);
int esxVI_GetStringValue(esxVI_ObjectContent *objectContent,
const char *propertyName,
- char **value, esxVI_Occurrence occurence);
+ char **value, esxVI_Occurrence occurrence);
int esxVI_GetManagedObjectReference(esxVI_ObjectContent *objectContent,
const char *propertyName,
esxVI_ManagedObjectReference **value,
- esxVI_Occurrence occurence);
+ esxVI_Occurrence occurrence);
int esxVI_LookupNumberOfDomainsByPowerState
(esxVI_Context *ctx, esxVI_VirtualMachinePowerState powerState,
--
1.7.0.4
1
0
This patch adds a couple of test cases for the recently added network
ipv6 support.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
---
scripts/networks/networkxml2hostout/tck-testnet-3.dat | 31
+++++++++++++
scripts/networks/networkxml2hostout/tck-testnet-3.post.dat | 12 +++++
scripts/networks/networkxml2xmlin/tck-testnet-3.xml | 22
+++++++++
3 files changed, 65 insertions(+)
Index: libvirt-tck/scripts/networks/networkxml2xmlin/tck-testnet-3.xml
===================================================================
--- /dev/null
+++ libvirt-tck/scripts/networks/networkxml2xmlin/tck-testnet-3.xml
@@ -0,0 +1,22 @@
+<network>
+ <name>tck-testnet</name>
+ <uuid>aadc8920-502a-4774-ac2b-cd382a204d06</uuid>
+ <bridge name="tck-testbr" />
+ <forward mode="nat" />
+ <ip address="10.1.2.1" netmask="255.255.255.0">
+ <dhcp>
+ <range start="10.1.2.2" end="10.1.2.254" />
+ <host mac="00:16:3e:77:e2:ed" name="a.example.com" ip="10.1.2.10" />
+ <host mac="00:16:3e:3e:a9:1a" name="b.example.com" ip="10.1.2.11" />
+ </dhcp>
+ </ip>
+ <ip family="ipv4" address="192.168.123.1" netmask="255.255.255.0">
+ </ip>
+ <ip family="ipv6" address="2001:db8:ac10:fe01::1" prefix="64">
+ </ip>
+ <ip family="ipv6" address="2001:db8:ac10:fd01::1" prefix="64">
+ </ip>
+ <ip family="ipv4" address="10.24.10.1">
+ </ip>
+</network>
+
Index: libvirt-tck/scripts/networks/networkxml2hostout/tck-testnet-3.dat
===================================================================
--- /dev/null
+++ libvirt-tck/scripts/networks/networkxml2hostout/tck-testnet-3.dat
@@ -0,0 +1,31 @@
+#iptables -t nat -L -n | grep ' 10\.1\.2\.'
+MASQUERADE tcp -- 10.1.2.0/24 !10.1.2.0/24 masq
ports: 1024-65535
+MASQUERADE udp -- 10.1.2.0/24 !10.1.2.0/24 masq
ports: 1024-65535
+MASQUERADE all -- 10.1.2.0/24 !10.1.2.0/24
+#iptables -n -L FORWARD | grep ' 10\.1\.2\.'
+ACCEPT all -- 0.0.0.0/0 10.1.2.0/24 state
RELATED,ESTABLISHED
+ACCEPT all -- 10.1.2.0/24 0.0.0.0/0
+#ip6tables -n -L FORWARD | grep ' 2001:db8:ac10'
+ACCEPT all ::/0 2001:db8:ac10:fd01::/64
+ACCEPT all 2001:db8:ac10:fd01::/64 ::/0
+ACCEPT all ::/0 2001:db8:ac10:fe01::/64
+ACCEPT all 2001:db8:ac10:fe01::/64 ::/0
+#ps aux | sed -n '/dnsmasq .*10\.1\.2\./ s|.*\(dnsmasq [[:print:]*]\)|\1|p'
+dnsmasq --strict-order --bind-interfaces
--pid-file=/var/run/libvirt/network/tck-testnet.pid --conf-file=
--listen-address 10.1.2.1 --except-interface lo --dhcp-range
10.1.2.2,10.1.2.254 --dhcp-lease-max=253 --dhcp-no-override
+#ps aux | sed -n '/radvd .*tck\-testnet\-/ s|.*\(radvd [[:print:]*]\)|\1|p'
+radvd --debug 1 --config /var/lib/libvirt/radvd/tck-testnet-radvd.conf
--pidfile /var/run/libvirt/network/tck-testnet-radvd.pid-bin
+#route -n | grep '10\.1\.2\.'
+10.1.2.0 0.0.0.0 255.255.255.0 U 0 0 0
tck-testbr
+#route -n | grep '192\.168\.123\.'
+192.168.123.0 0.0.0.0 255.255.255.0 U 0 0 0
tck-testbr
+#route -n | grep '10\.0\.0\.0'
+10.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0
tck-testbr
+#brctl show | grep tck-testbr
+tck-testbr 8000.000000000000 yes
+#ifconfig tck-testbr | grep ':10\.1\.2\.'
+ inet addr:10.1.2.1 Bcast:10.1.2.255 Mask:255.255.255.0
+#ifconfig tck-testbr | grep 'inet6 addr: 2001'
+ inet6 addr: 2001:db8:ac10:fd01::1/64 Scope:Global
+ inet6 addr: 2001:db8:ac10:fe01::1/64 Scope:Global
+#virsh net-list | grep tck-testnet
+tck-testnet active no
Index:
libvirt-tck/scripts/networks/networkxml2hostout/tck-testnet-3.post.dat
===================================================================
--- /dev/null
+++ libvirt-tck/scripts/networks/networkxml2hostout/tck-testnet-3.post.dat
@@ -0,0 +1,12 @@
+#iptables -t nat -L -n | grep ' 10\.1\.2\.'
+#iptables -n -L FORWARD | grep ' 10\.1\.2\.'
+#ip6tables -n -L FORWARD | grep ' 2001:db8:ac10'
+#ps aux | sed -n '/dnsmasq .*10\.1\.2\./ s|.*\(dnsmasq [[:print:]*]\)|\1|p'
+#ps aux | sed -n '/radvd .*tck\-testnet\-/ s|.*\(radvd [[:print:]*]\)|\1|p'
+#route -n | grep '10\.1\.2\.'
+#route -n | grep '192\.168\.123\.'
+#route -n | grep '10\.0\.0\.0'
+#brctl show | grep tck-testbr
+#ifconfig tck-testbr 2>/dev/null | grep ':10\.1\.2\.'
+#ifconfig tck-testbr 2>/dev/null | grep 'inet6 addr: 2001'
+#virsh net-list | grep tck-testnet
1
0
Add vboxArrayGetWithUintArg to handle new signature variations. Also
refactor vboxArrayGet* implementation to use a common helper function.
Deal with the incompatible changes in the VirtualBox 4.0 API. This
includes major changes in virtual machine and storage medium lookup,
in RDP server property handling, in session/lock handling and other
minor areas.
VirtualBox 4.0 also dropped the old event API and replaced it with a
completely new one. This is not fixed yet and will be addressed in
another patch. Therefore, currently the domain events are supported
for VirtualBox 3.x only.
Based on initial work from Jean-Baptiste Rouault.
---
This mail omits the 7451 lines of addition for the vbox_CAPI_v4_0.h
file on purpose. vbox_CAPI_v4_0.h is taken from the VirtualBox 4.0 SDK
and got the same treatment as the other vbox_CAPI_v*.h files. Like
the note about not to regenerate it in the context of libvirt, it's
preprocessor code is indented to pass the syntax-check, all methods
are marked with __stdcall on Windows, etc.
Matthias
src/Makefile.am | 3 +-
src/vbox/vbox_CAPI_v4_0.h | 7451 ++++++++++++++++++++++++++++++++++++++++++++
src/vbox/vbox_MSCOMGlue.c | 65 +-
src/vbox/vbox_MSCOMGlue.h | 3 +-
src/vbox/vbox_V4_0.c | 13 +
src/vbox/vbox_XPCOMCGlue.c | 58 +-
src/vbox/vbox_XPCOMCGlue.h | 3 +-
src/vbox/vbox_driver.c | 8 +
src/vbox/vbox_tmpl.c | 489 +++-
9 files changed, 7923 insertions(+), 170 deletions(-)
create mode 100644 src/vbox/vbox_CAPI_v4_0.h
create mode 100644 src/vbox/vbox_V4_0.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 41d4b34..c13724a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -264,7 +264,8 @@ VBOX_DRIVER_SOURCES = \
vbox/vbox_V2_2.c vbox/vbox_CAPI_v2_2.h \
vbox/vbox_V3_0.c vbox/vbox_CAPI_v3_0.h \
vbox/vbox_V3_1.c vbox/vbox_CAPI_v3_1.h \
- vbox/vbox_V3_2.c vbox/vbox_CAPI_v3_2.h
+ vbox/vbox_V3_2.c vbox/vbox_CAPI_v3_2.h \
+ vbox/vbox_V4_0.c vbox/vbox_CAPI_v4_0.h
VBOX_DRIVER_EXTRA_DIST = \
vbox/vbox_tmpl.c vbox/README \
diff --git a/src/vbox/vbox_MSCOMGlue.c b/src/vbox/vbox_MSCOMGlue.c
index cf68d38..e6a886f 100644
--- a/src/vbox/vbox_MSCOMGlue.c
+++ b/src/vbox/vbox_MSCOMGlue.c
@@ -660,25 +660,18 @@ VBoxCGlueTerm(void)
*/
typedef HRESULT __stdcall (*SafeArrayGetter)(void *self, SAFEARRAY **array);
-typedef HRESULT __stdcall (*SafeArrayGetterWithArg)(void *self, void *arg, SAFEARRAY **array);
+typedef HRESULT __stdcall (*SafeArrayGetterWithPtrArg)(void *self, void *arg, SAFEARRAY **array);
+typedef HRESULT __stdcall (*SafeArrayGetterWithUintArg)(void *self, PRUint32 arg, SAFEARRAY **array);
-/*
- * Call the getter with self as first argument and fill the array with the
- * returned items.
- */
-nsresult
-vboxArrayGet(vboxArray *array, void *self, void *getter)
+static nsresult
+vboxArrayGetHelper(vboxArray *array, HRESULT hrc, SAFEARRAY *safeArray)
{
- HRESULT hrc;
- SAFEARRAY *safeArray = NULL;
void **items = NULL;
array->items = NULL;
array->count = 0;
array->handle = NULL;
- hrc = ((SafeArrayGetter)getter)(self, &safeArray);
-
if (FAILED(hrc)) {
return hrc;
}
@@ -698,38 +691,48 @@ vboxArrayGet(vboxArray *array, void *self, void *getter)
}
/*
- * Call the getter with self as first argument and arg as second argument
- * and fill the array with the returned items.
+ * Call the getter with self as first argument and fill the array with the
+ * returned items.
*/
nsresult
-vboxArrayGetWithArg(vboxArray *array, void *self, void *getter, void *arg)
+vboxArrayGet(vboxArray *array, void *self, void *getter)
{
HRESULT hrc;
SAFEARRAY *safeArray = NULL;
- void **items = NULL;
- array->items = NULL;
- array->count = 0;
- array->handle = NULL;
+ hrc = ((SafeArrayGetter)getter)(self, &safeArray);
- hrc = ((SafeArrayGetterWithArg)getter)(self, arg, &safeArray);
+ return vboxArrayGetHelper(array, hrc, safeArray);
+}
- if (FAILED(hrc)) {
- return hrc;
- }
+/*
+ * Call the getter with self as first argument and arg as second argument
+ * and fill the array with the returned items.
+ */
+nsresult
+vboxArrayGetWithPtrArg(vboxArray *array, void *self, void *getter, void *arg)
+{
+ HRESULT hrc;
+ SAFEARRAY *safeArray = NULL;
- hrc = SafeArrayAccessData(safeArray, (void **)&items);
+ hrc = ((SafeArrayGetterWithPtrArg)getter)(self, arg, &safeArray);
- if (FAILED(hrc)) {
- SafeArrayDestroy(safeArray);
- return hrc;
- }
+ return vboxArrayGetHelper(array, hrc, safeArray);
+}
- array->items = items;
- array->count = safeArray->rgsabound[0].cElements;
- array->handle = safeArray;
+/*
+ * Call the getter with self as first argument and arg as second argument
+ * and fill the array with the returned items.
+ */
+nsresult
+vboxArrayGetWithUintArg(vboxArray *array, void *self, void *getter, PRUint32 arg)
+{
+ HRESULT hrc;
+ SAFEARRAY *safeArray = NULL;
- return hrc;
+ hrc = ((SafeArrayGetterWithUintArg)getter)(self, arg, &safeArray);
+
+ return vboxArrayGetHelper(array, hrc, safeArray);
}
/*
diff --git a/src/vbox/vbox_MSCOMGlue.h b/src/vbox/vbox_MSCOMGlue.h
index f1d6c74..83b2ce1 100644
--- a/src/vbox/vbox_MSCOMGlue.h
+++ b/src/vbox/vbox_MSCOMGlue.h
@@ -41,7 +41,8 @@ struct _vboxArray {
# define VBOX_ARRAY_INITIALIZER { NULL, 0, NULL }
nsresult vboxArrayGet(vboxArray *array, void *self, void *getter);
-nsresult vboxArrayGetWithArg(vboxArray *array, void *self, void *getter, void *arg);
+nsresult vboxArrayGetWithPtrArg(vboxArray *array, void *self, void *getter, void *arg);
+nsresult vboxArrayGetWithUintArg(vboxArray *array, void *self, void *getter, PRUint32 arg);
void vboxArrayRelease(vboxArray *array);
# define vboxArrayUnalloc vboxArrayRelease
diff --git a/src/vbox/vbox_V4_0.c b/src/vbox/vbox_V4_0.c
new file mode 100644
index 0000000..f976a1a
--- /dev/null
+++ b/src/vbox/vbox_V4_0.c
@@ -0,0 +1,13 @@
+/** @file vbox_V4_0.c
+ * C file to include support for multiple versions of VirtualBox
+ * at runtime.
+ */
+
+#include <config.h>
+
+/** The API Version */
+#define VBOX_API_VERSION 4000
+/** Version specific prefix. */
+#define NAME(name) vbox40##name
+
+#include "vbox_tmpl.c"
diff --git a/src/vbox/vbox_XPCOMCGlue.c b/src/vbox/vbox_XPCOMCGlue.c
index dcaf682..fbe210c 100644
--- a/src/vbox/vbox_XPCOMCGlue.c
+++ b/src/vbox/vbox_XPCOMCGlue.c
@@ -264,7 +264,24 @@ VBoxCGlueTerm(void)
*/
typedef nsresult (*ArrayGetter)(void *self, PRUint32 *count, void ***items);
-typedef nsresult (*ArrayGetterWithArg)(void *self, void *arg, PRUint32 *count, void ***items);
+typedef nsresult (*ArrayGetterWithPtrArg)(void *self, void *arg, PRUint32 *count, void ***items);
+typedef nsresult (*ArrayGetterWithUintArg)(void *self, PRUint32 arg, PRUint32 *count, void ***items);
+
+static nsresult
+vboxArrayGetHelper(vboxArray *array, nsresult nsrc, void **items, PRUint32 count)
+{
+ array->items = NULL;
+ array->count = 0;
+
+ if (NS_FAILED(nsrc)) {
+ return nsrc;
+ }
+
+ array->items = items;
+ array->count = count;
+
+ return nsrc;
+}
/*
* Call the getter with self as first argument and fill the array with the
@@ -277,19 +294,9 @@ vboxArrayGet(vboxArray *array, void *self, void *getter)
void **items = NULL;
PRUint32 count = 0;
- array->items = NULL;
- array->count = 0;
-
nsrc = ((ArrayGetter)getter)(self, &count, &items);
- if (NS_FAILED(nsrc)) {
- return nsrc;
- }
-
- array->items = items;
- array->count = count;
-
- return nsrc;
+ return vboxArrayGetHelper(array, nsrc, items, count);
}
/*
@@ -297,25 +304,31 @@ vboxArrayGet(vboxArray *array, void *self, void *getter)
* and fill the array with the returned items.
*/
nsresult
-vboxArrayGetWithArg(vboxArray *array, void *self, void *getter, void *arg)
+vboxArrayGetWithPtrArg(vboxArray *array, void *self, void *getter, void *arg)
{
nsresult nsrc;
void **items = NULL;
PRUint32 count = 0;
- array->items = NULL;
- array->count = 0;
+ nsrc = ((ArrayGetterWithPtrArg)getter)(self, arg, &count, &items);
- nsrc = ((ArrayGetterWithArg)getter)(self, arg, &count, &items);
+ return vboxArrayGetHelper(array, nsrc, items, count);
+}
- if (NS_FAILED(nsrc)) {
- return nsrc;
- }
+/*
+ * Call the getter with self as first argument and arg as second argument
+ * and fill the array with the returned items.
+ */
+nsresult
+vboxArrayGetWithUintArg(vboxArray *array, void *self, void *getter, PRUint32 arg)
+{
+ nsresult nsrc;
+ void **items = NULL;
+ PRUint32 count = 0;
- array->items = items;
- array->count = count;
+ nsrc = ((ArrayGetterWithUintArg)getter)(self, arg, &count, &items);
- return nsrc;
+ return vboxArrayGetHelper(array, nsrc, items, count);
}
/*
@@ -345,7 +358,6 @@ vboxArrayRelease(vboxArray *array)
array->count = 0;
}
-
/*
* Unalloc all items in the array and reset it.
*/
diff --git a/src/vbox/vbox_XPCOMCGlue.h b/src/vbox/vbox_XPCOMCGlue.h
index 8fd2f13..2a50404 100644
--- a/src/vbox/vbox_XPCOMCGlue.h
+++ b/src/vbox/vbox_XPCOMCGlue.h
@@ -48,7 +48,8 @@ struct _vboxArray {
# define VBOX_ARRAY_INITIALIZER { NULL, 0 }
nsresult vboxArrayGet(vboxArray *array, void *self, void *getter);
-nsresult vboxArrayGetWithArg(vboxArray *array, void *self, void *getter, void *arg);
+nsresult vboxArrayGetWithPtrArg(vboxArray *array, void *self, void *getter, void *arg);
+nsresult vboxArrayGetWithUintArg(vboxArray *array, void *self, void *getter, PRUint32 arg);
void vboxArrayRelease(vboxArray *array);
void vboxArrayUnalloc(vboxArray *array);
diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c
index b39a63b..f647eb9 100644
--- a/src/vbox/vbox_driver.c
+++ b/src/vbox/vbox_driver.c
@@ -57,6 +57,9 @@ extern virStorageDriver vbox31StorageDriver;
extern virDriver vbox32Driver;
extern virNetworkDriver vbox32NetworkDriver;
extern virStorageDriver vbox32StorageDriver;
+extern virDriver vbox40Driver;
+extern virNetworkDriver vbox40NetworkDriver;
+extern virStorageDriver vbox40StorageDriver;
static virDriver vboxDriverDummy;
@@ -114,6 +117,11 @@ int vboxRegister(void) {
driver = &vbox32Driver;
networkDriver = &vbox32NetworkDriver;
storageDriver = &vbox32StorageDriver;
+ } else if (uVersion >= 3002051 && uVersion < 4000051) {
+ DEBUG0("VirtualBox API version: 4.0");
+ driver = &vbox40Driver;
+ networkDriver = &vbox40NetworkDriver;
+ storageDriver = &vbox40StorageDriver;
} else {
DEBUG0("Unsupport VirtualBox API version");
}
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 2b170ec..f45e8ed 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -62,6 +62,8 @@
# include "vbox_CAPI_v3_1.h"
#elif VBOX_API_VERSION == 3002
# include "vbox_CAPI_v3_2.h"
+#elif VBOX_API_VERSION == 4000
+# include "vbox_CAPI_v4_0.h"
#else
# error "Unsupport VBOX_API_VERSION"
#endif
@@ -79,9 +81,13 @@
#define VBOX_ADDREF(arg) (arg)->vtbl->nsisupports.AddRef((nsISupports *)(arg))
-#define VBOX_RELEASE(arg) \
-if(arg)\
- (arg)->vtbl->nsisupports.Release((nsISupports *)(arg))
+#define VBOX_RELEASE(arg) \
+ do { \
+ if (arg) { \
+ (arg)->vtbl->nsisupports.Release((nsISupports *)(arg)); \
+ (arg) = NULL; \
+ } \
+ } while (0)
#define VBOX_OBJECT_CHECK(conn, type, value) \
vboxGlobalData *data = conn->privateData;\
@@ -182,7 +188,10 @@ typedef struct {
int fdWatch;
int domainEventDispatching;
+# if VBOX_API_VERSION <= 3002
+ /* IVirtualBoxCallback is used in VirtualBox 3.x only */
IVirtualBoxCallback *vboxCallback;
+# endif /* VBOX_API_VERSION <= 3002 */
nsIEventQueue *vboxQueue;
int volatile vboxCallBackRefCount;
@@ -206,6 +215,36 @@ static vboxGlobalData *g_pVBoxGlobalData = NULL;
#endif /* !(VBOX_API_VERSION == 2002) */
+#if VBOX_API_VERSION < 4000
+
+# define VBOX_OBJECT_GET_MACHINE(/* in */ iid_value, /* out */ machine) \
+ data->vboxObj->vtbl->GetMachine(data->vboxObj, iid_value, machine)
+
+# define VBOX_SESSION_OPEN(/* in */ iid_value, /* unused */ machine) \
+ data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid_value)
+
+# define VBOX_SESSION_OPEN_EXISTING(/* in */ iid_value, /* unused */ machine) \
+ data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid_value)
+
+# define VBOX_SESSION_CLOSE() \
+ data->vboxSession->vtbl->Close(data->vboxSession)
+
+#else /* VBOX_API_VERSION >= 4000 */
+
+# define VBOX_OBJECT_GET_MACHINE(/* in */ iid_value, /* out */ machine) \
+ data->vboxObj->vtbl->FindMachine(data->vboxObj, iid_value, machine)
+
+# define VBOX_SESSION_OPEN(/* unused */ iid_value, /* in */ machine) \
+ machine->vtbl->LockMachine(machine, data->vboxSession, LockType_Write)
+
+# define VBOX_SESSION_OPEN_EXISTING(/* unused */ iid_value, /* in */ machine) \
+ machine->vtbl->LockMachine(machine, data->vboxSession, LockType_Shared)
+
+# define VBOX_SESSION_CLOSE() \
+ data->vboxSession->vtbl->UnlockMachine(data->vboxSession)
+
+#endif /* VBOX_API_VERSION >= 4000 */
+
static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml);
static int vboxDomainCreate(virDomainPtr dom);
static int vboxDomainUndefine(virDomainPtr dom);
@@ -1451,7 +1490,7 @@ static int vboxDomainSuspend(virDomainPtr dom) {
nsresult rc;
vboxIIDFromUUID(&iid, dom->uuid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
+ rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
@@ -1466,8 +1505,8 @@ static int vboxDomainSuspend(virDomainPtr dom) {
machine->vtbl->GetState(machine, &state);
if (state == MachineState_Running) {
- /* set state pause */
- data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
+ /* set state pause */
+ VBOX_SESSION_OPEN_EXISTING(iid.value, machine);
data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (console) {
console->vtbl->Pause(console);
@@ -1478,7 +1517,7 @@ static int vboxDomainSuspend(virDomainPtr dom) {
_("error while suspending the domain"));
goto cleanup;
}
- data->vboxSession->vtbl->Close(data->vboxSession);
+ VBOX_SESSION_CLOSE();
} else {
vboxError(VIR_ERR_OPERATION_FAILED, "%s",
_("machine not in running state to suspend it"));
@@ -1503,7 +1542,7 @@ static int vboxDomainResume(virDomainPtr dom) {
PRBool isAccessible = PR_FALSE;
vboxIIDFromUUID(&iid, dom->uuid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
+ rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
@@ -1518,8 +1557,8 @@ static int vboxDomainResume(virDomainPtr dom) {
machine->vtbl->GetState(machine, &state);
if (state == MachineState_Paused) {
- /* resume the machine here */
- data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
+ /* resume the machine here */
+ VBOX_SESSION_OPEN_EXISTING(iid.value, machine);
data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (console) {
console->vtbl->Resume(console);
@@ -1530,7 +1569,7 @@ static int vboxDomainResume(virDomainPtr dom) {
_("error while resuming the domain"));
goto cleanup;
}
- data->vboxSession->vtbl->Close(data->vboxSession);
+ VBOX_SESSION_CLOSE();
} else {
vboxError(VIR_ERR_OPERATION_FAILED, "%s",
_("machine not paused, so can't resume it"));
@@ -1554,7 +1593,7 @@ static int vboxDomainShutdown(virDomainPtr dom) {
nsresult rc;
vboxIIDFromUUID(&iid, dom->uuid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
+ rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
@@ -1578,14 +1617,14 @@ static int vboxDomainShutdown(virDomainPtr dom) {
goto cleanup;
}
- data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
+ VBOX_SESSION_OPEN_EXISTING(iid.value, machine);
data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (console) {
console->vtbl->PowerButton(console);
VBOX_RELEASE(console);
ret = 0;
}
- data->vboxSession->vtbl->Close(data->vboxSession);
+ VBOX_SESSION_CLOSE();
}
cleanup:
@@ -1604,7 +1643,7 @@ static int vboxDomainReboot(virDomainPtr dom, unsigned int flags ATTRIBUTE_UNUSE
nsresult rc;
vboxIIDFromUUID(&iid, dom->uuid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
+ rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
@@ -1619,14 +1658,14 @@ static int vboxDomainReboot(virDomainPtr dom, unsigned int flags ATTRIBUTE_UNUSE
machine->vtbl->GetState(machine, &state);
if (state == MachineState_Running) {
- data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
+ VBOX_SESSION_OPEN_EXISTING(iid.value, machine);
data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (console) {
console->vtbl->Reset(console);
VBOX_RELEASE(console);
ret = 0;
}
- data->vboxSession->vtbl->Close(data->vboxSession);
+ VBOX_SESSION_CLOSE();
} else {
vboxError(VIR_ERR_OPERATION_FAILED, "%s",
_("machine not running, so can't reboot it"));
@@ -1650,7 +1689,7 @@ static int vboxDomainDestroy(virDomainPtr dom) {
nsresult rc;
vboxIIDFromUUID(&iid, dom->uuid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
+ rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
@@ -1670,7 +1709,7 @@ static int vboxDomainDestroy(virDomainPtr dom) {
goto cleanup;
}
- data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
+ VBOX_SESSION_OPEN_EXISTING(iid.value, machine);
data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (console) {
@@ -1688,7 +1727,7 @@ static int vboxDomainDestroy(virDomainPtr dom) {
dom->id = -1;
ret = 0;
}
- data->vboxSession->vtbl->Close(data->vboxSession);
+ VBOX_SESSION_CLOSE();
}
cleanup:
@@ -1720,7 +1759,7 @@ static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) {
nsresult rc;
vboxIIDFromUUID(&iid, dom->uuid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
+ rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
@@ -1740,7 +1779,7 @@ static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) {
goto cleanup;
}
- rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid.value);
+ rc = VBOX_SESSION_OPEN(iid.value, machine);
if (NS_SUCCEEDED(rc)) {
rc = data->vboxSession->vtbl->GetMachine(data->vboxSession, &machine);
if (NS_SUCCEEDED(rc) && machine) {
@@ -1756,7 +1795,7 @@ static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) {
memory, (unsigned)rc);
}
}
- data->vboxSession->vtbl->Close(data->vboxSession);
+ VBOX_SESSION_CLOSE();
}
}
@@ -1874,6 +1913,7 @@ static int vboxDomainSave(virDomainPtr dom, const char *path ATTRIBUTE_UNUSED) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IConsole *console = NULL;
vboxIID iid = VBOX_IID_INITIALIZER;
+ IMachine *machine = NULL;
nsresult rc;
/* VirtualBox currently doesn't support saving to a file
@@ -1885,7 +1925,17 @@ static int vboxDomainSave(virDomainPtr dom, const char *path ATTRIBUTE_UNUSED) {
/* Open a Session for the machine */
vboxIIDFromUUID(&iid, dom->uuid);
- rc = data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
+#if VBOX_API_VERSION >= 4000
+ /* Get machine for the call to VBOX_SESSION_OPEN_EXISTING */
+ rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
+ if (NS_FAILED(rc)) {
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
+ _("no domain with matching uuid"));
+ return -1;
+ }
+#endif
+
+ rc = VBOX_SESSION_OPEN_EXISTING(iid.value, machine);
if (NS_SUCCEEDED(rc)) {
rc = data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (NS_SUCCEEDED(rc) && console) {
@@ -1909,11 +1959,12 @@ static int vboxDomainSave(virDomainPtr dom, const char *path ATTRIBUTE_UNUSED) {
}
VBOX_RELEASE(console);
}
- data->vboxSession->vtbl->Close(data->vboxSession);
+ VBOX_SESSION_CLOSE();
}
DEBUGIID("UUID of machine being saved:", iid.value);
+ VBOX_RELEASE(machine);
vboxIIDUnalloc(&iid);
return ret;
}
@@ -1934,7 +1985,17 @@ vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
}
vboxIIDFromUUID(&iid, dom->uuid);
- rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid.value);
+#if VBOX_API_VERSION >= 4000
+ /* Get machine for the call to VBOX_SESSION_OPEN */
+ rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
+ if (NS_FAILED(rc)) {
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
+ _("no domain with matching uuid"));
+ return -1;
+ }
+#endif
+
+ rc = VBOX_SESSION_OPEN(iid.value, machine);
if (NS_SUCCEEDED(rc)) {
data->vboxSession->vtbl->GetMachine(data->vboxSession, &machine);
if (machine) {
@@ -1957,7 +2018,7 @@ vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
vboxError(VIR_ERR_NO_DOMAIN,
_("can't open session to the domain with id %d"), dom->id);
}
- data->vboxSession->vtbl->Close(data->vboxSession);
+ VBOX_SESSION_CLOSE();
vboxIIDUnalloc(&iid);
return ret;
@@ -2020,7 +2081,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
}
vboxIIDFromUUID(&iid, dom->uuid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
+ rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
if (NS_SUCCEEDED(rc)) {
PRBool accessible = PR_FALSE;
@@ -2031,7 +2092,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
PRBool PAEEnabled = PR_FALSE;
PRBool ACPIEnabled = PR_FALSE;
PRBool IOAPICEnabled = PR_FALSE;
- PRBool VRDPEnabled = PR_FALSE;
+ PRBool VRDxEnabled = PR_FALSE;
PRUint32 CPUCount = 0;
PRUint32 memorySize = 0;
PRUint32 netAdpCnt = 0;
@@ -2056,7 +2117,11 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
#else /* VBOX_API_VERSION >= 3001 */
vboxArray mediumAttachments = VBOX_ARRAY_INITIALIZER;
#endif /* VBOX_API_VERSION >= 3001 */
- IVRDPServer *VRDPServer = NULL;
+#if VBOX_API_VERSION < 4000
+ IVRDPServer *VRDxServer = NULL;
+#else /* VBOX_API_VERSION >= 4000 */
+ IVRDEServer *VRDxServer = NULL;
+#endif /* VBOX_API_VERSION >= 4000 */
IAudioAdapter *audioAdapter = NULL;
IUSBController *USBController = NULL;
ISystemProperties *systemProperties = NULL;
@@ -2296,10 +2361,14 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
}
}
- machine->vtbl->GetVRDPServer(machine, &VRDPServer);
- if (VRDPServer) {
- VRDPServer->vtbl->GetEnabled(VRDPServer, &VRDPEnabled);
- if (VRDPEnabled) {
+#if VBOX_API_VERSION < 4000
+ machine->vtbl->GetVRDPServer(machine, &VRDxServer);
+#else /* VBOX_API_VERSION >= 4000 */
+ machine->vtbl->GetVRDEServer(machine, &VRDxServer);
+#endif /* VBOX_API_VERSION >= 4000 */
+ if (VRDxServer) {
+ VRDxServer->vtbl->GetEnabled(VRDxServer, &VRDxEnabled);
+ if (VRDxEnabled) {
totalPresent++;
@@ -2311,24 +2380,41 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
PRBool reuseSingleConnection = PR_FALSE;
#if VBOX_API_VERSION < 3001
PRUint32 VRDPport = 0;
- VRDPServer->vtbl->GetPort(VRDPServer, &VRDPport);
+ VRDxServer->vtbl->GetPort(VRDxServer, &VRDPport);
if (VRDPport) {
def->graphics[def->ngraphics]->data.rdp.port = VRDPport;
-#else /* VBOX_API_VERSION >= 3001 */
+#elif VBOX_API_VERSION < 4000 /* 3001 <= VBOX_API_VERSION < 4000 */
PRUnichar *VRDPport = NULL;
- VRDPServer->vtbl->GetPorts(VRDPServer, &VRDPport);
+ VRDxServer->vtbl->GetPorts(VRDxServer, &VRDPport);
if (VRDPport) {
/* even if vbox supports mutilpe ports, single port for now here */
def->graphics[def->ngraphics]->data.rdp.port = PRUnicharToInt(VRDPport);
VBOX_UTF16_FREE(VRDPport);
-#endif /* VBOX_API_VERSION >= 3001 */
+#else /* VBOX_API_VERSION >= 4000 */
+ PRUnichar *VRDEPortsKey = NULL;
+ PRUnichar *VRDEPortsValue = NULL;
+ VBOX_UTF8_TO_UTF16("TCP/Ports", &VRDEPortsKey);
+ VRDxServer->vtbl->GetVRDEProperty(VRDxServer, VRDEPortsKey, &VRDEPortsValue);
+ VBOX_UTF16_FREE(VRDEPortsKey);
+ if (VRDEPortsValue) {
+ /* even if vbox supports mutilpe ports, single port for now here */
+ def->graphics[def->ngraphics]->data.rdp.port = PRUnicharToInt(VRDEPortsValue);
+ VBOX_UTF16_FREE(VRDEPortsValue);
+#endif /* VBOX_API_VERSION >= 4000 */
} else {
def->graphics[def->ngraphics]->data.rdp.autoport = 1;
}
def->graphics[def->ngraphics]->type = VIR_DOMAIN_GRAPHICS_TYPE_RDP;
- VRDPServer->vtbl->GetNetAddress(VRDPServer, &netAddressUtf16);
+#if VBOX_API_VERSION >= 4000
+ PRUnichar *VRDENetAddressKey = NULL;
+ VBOX_UTF8_TO_UTF16("TCP/Address", &VRDENetAddressKey);
+ VRDxServer->vtbl->GetVRDEProperty(VRDxServer, VRDENetAddressKey, &netAddressUtf16);
+ VBOX_UTF16_FREE(VRDENetAddressKey);
+#else /* VBOX_API_VERSION < 4000 */
+ VRDxServer->vtbl->GetNetAddress(VRDxServer, &netAddressUtf16);
+#endif /* VBOX_API_VERSION < 4000 */
if (netAddressUtf16) {
VBOX_UTF16_TO_UTF8(netAddressUtf16, &netAddressUtf8);
if (STRNEQ(netAddressUtf8, ""))
@@ -2337,12 +2423,12 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
VBOX_UTF8_FREE(netAddressUtf8);
}
- VRDPServer->vtbl->GetAllowMultiConnection(VRDPServer, &allowMultiConnection);
+ VRDxServer->vtbl->GetAllowMultiConnection(VRDxServer, &allowMultiConnection);
if (allowMultiConnection) {
def->graphics[def->ngraphics]->data.rdp.multiUser = 1;
}
- VRDPServer->vtbl->GetReuseSingleConnection(VRDPServer, &reuseSingleConnection);
+ VRDxServer->vtbl->GetReuseSingleConnection(VRDxServer, &reuseSingleConnection);
if (reuseSingleConnection) {
def->graphics[def->ngraphics]->data.rdp.replaceUser = 1;
}
@@ -2351,7 +2437,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
} else
virReportOOMError();
}
- VBOX_RELEASE(VRDPServer);
+ VBOX_RELEASE(VRDxServer);
}
}
@@ -3218,7 +3304,8 @@ cleanup:
static int
-vboxStartMachine(virDomainPtr dom, int i, IMachine *machine, vboxIID *iid)
+vboxStartMachine(virDomainPtr dom, int i, IMachine *machine,
+ vboxIID *iid ATTRIBUTE_UNUSED /* >= 4.0 */)
{
VBOX_OBJECT_CHECK(dom->conn, int, -1);
int vrdpPresent = 0;
@@ -3344,15 +3431,21 @@ vboxStartMachine(virDomainPtr dom, int i, IMachine *machine, vboxIID *iid)
VBOX_UTF8_TO_UTF16("vrdp", &sessionType);
}
+#if VBOX_API_VERSION < 4000
rc = data->vboxObj->vtbl->OpenRemoteSession(data->vboxObj,
data->vboxSession,
iid->value,
sessionType,
env,
&progress );
+#else /* VBOX_API_VERSION >= 4000 */
+ rc = machine->vtbl->LaunchVMProcess(machine, data->vboxSession,
+ sessionType, env, &progress);
+#endif /* VBOX_API_VERSION >= 4000 */
+
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_OPERATION_FAILED, "%s",
- _("openremotesession failed, domain can't be started"));
+ _("OpenRemoteSession/LaunchVMProcess failed, domain can't be started"));
ret = -1;
} else {
PRBool completed = 0;
@@ -3380,7 +3473,7 @@ vboxStartMachine(virDomainPtr dom, int i, IMachine *machine, vboxIID *iid)
VBOX_RELEASE(progress);
- data->vboxSession->vtbl->Close(data->vboxSession);
+ VBOX_SESSION_CLOSE();
VBOX_UTF16_FREE(env);
VBOX_UTF16_FREE(sessionType);
@@ -3822,6 +3915,7 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
PRUnichar *mediumFileUtf16 = NULL;
PRUint32 storageBus = StorageBus_Null;
PRUint32 deviceType = DeviceType_Null;
+ PRUint32 accessMode = AccessMode_ReadOnly;
PRInt32 deviceInst = 0;
PRInt32 devicePort = 0;
PRInt32 deviceSlot = 0;
@@ -3830,26 +3924,41 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
deviceType = DeviceType_HardDisk;
+ accessMode = AccessMode_ReadWrite;
+# if VBOX_API_VERSION < 4000
data->vboxObj->vtbl->FindHardDisk(data->vboxObj,
mediumFileUtf16, &medium);
+# endif
} else if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
deviceType = DeviceType_DVD;
+ accessMode = AccessMode_ReadOnly;
+# if VBOX_API_VERSION < 4000
data->vboxObj->vtbl->FindDVDImage(data->vboxObj,
mediumFileUtf16, &medium);
+# endif
} else if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
deviceType = DeviceType_Floppy;
+ accessMode = AccessMode_ReadWrite;
+# if VBOX_API_VERSION < 4000
data->vboxObj->vtbl->FindFloppyImage(data->vboxObj,
mediumFileUtf16, &medium);
+# endif
} else {
VBOX_UTF16_FREE(mediumFileUtf16);
continue;
}
+# if VBOX_API_VERSION >= 4000
+ data->vboxObj->vtbl->FindMedium(data->vboxObj, mediumFileUtf16,
+ deviceType, &medium);
+# endif
+
if (!medium) {
PRUnichar *mediumEmpty = NULL;
VBOX_UTF8_TO_UTF16("", &mediumEmpty);
+# if VBOX_API_VERSION < 4000
if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
rc = data->vboxObj->vtbl->OpenHardDisk(data->vboxObj,
mediumFileUtf16,
@@ -3874,6 +3983,12 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
} else {
rc = 0;
}
+# else /* VBOX_API_VERSION >= 4000 */
+ rc = data->vboxObj->vtbl->OpenMedium(data->vboxObj,
+ mediumFileUtf16,
+ deviceType, accessMode,
+ &medium);
+# endif /* VBOX_API_VERSION >= 4000 */
VBOX_UTF16_FREE(mediumEmpty);
}
@@ -3946,7 +4061,11 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
devicePort,
deviceSlot,
deviceType,
+# if VBOX_API_VERSION < 4000
mediumUUID);
+# else /* VBOX_API_VERSION >= 4000 */
+ medium);
+# endif /* VBOX_API_VERSION >= 4000 */
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
@@ -4307,20 +4426,28 @@ vboxAttachDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
int i = 0;
for (i = 0; i < def->ngraphics; i++) {
- IVRDPServer *VRDPServer = NULL;
+#if VBOX_API_VERSION < 4000
+ IVRDPServer *VRDxServer = NULL;
+#else /* VBOX_API_VERSION >= 4000 */
+ IVRDEServer *VRDxServer = NULL;
+#endif /* VBOX_API_VERSION >= 4000 */
if ((def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_RDP) &&
(vrdpPresent == 0)) {
vrdpPresent = 1;
- machine->vtbl->GetVRDPServer(machine, &VRDPServer);
- if (VRDPServer) {
- VRDPServer->vtbl->SetEnabled(VRDPServer, PR_TRUE);
+#if VBOX_API_VERSION < 4000
+ machine->vtbl->GetVRDPServer(machine, &VRDxServer);
+#else /* VBOX_API_VERSION >= 4000 */
+ machine->vtbl->GetVRDEServer(machine, &VRDxServer);
+#endif /* VBOX_API_VERSION >= 4000 */
+ if (VRDxServer) {
+ VRDxServer->vtbl->SetEnabled(VRDxServer, PR_TRUE);
DEBUG0("VRDP Support turned ON.");
#if VBOX_API_VERSION < 3001
if (def->graphics[i]->data.rdp.port) {
- VRDPServer->vtbl->SetPort(VRDPServer,
+ VRDxServer->vtbl->SetPort(VRDxServer,
def->graphics[i]->data.rdp.port);
DEBUG("VRDP Port changed to: %d",
def->graphics[i]->data.rdp.port);
@@ -4328,42 +4455,61 @@ vboxAttachDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
/* Setting the port to 0 will reset its value to
* the default one which is 3389 currently
*/
- VRDPServer->vtbl->SetPort(VRDPServer, 0);
+ VRDxServer->vtbl->SetPort(VRDxServer, 0);
DEBUG0("VRDP Port changed to default, which is 3389 currently");
}
-#else /* VBOX_API_VERSION >= 3001 */
+#elif VBOX_API_VERSION < 4000 /* 3001 <= VBOX_API_VERSION < 4000 */
PRUnichar *portUtf16 = NULL;
portUtf16 = PRUnicharFromInt(def->graphics[i]->data.rdp.port);
- VRDPServer->vtbl->SetPorts(VRDPServer, portUtf16);
+ VRDxServer->vtbl->SetPorts(VRDxServer, portUtf16);
VBOX_UTF16_FREE(portUtf16);
-#endif /* VBOX_API_VERSION >= 3001 */
+#else /* VBOX_API_VERSION >= 4000 */
+ PRUnichar *VRDEPortsKey = NULL;
+ PRUnichar *VRDEPortsValue = NULL;
+ VBOX_UTF8_TO_UTF16("TCP/Ports", &VRDEPortsKey);
+ VRDEPortsValue = PRUnicharFromInt(def->graphics[i]->data.rdp.port);
+ VRDxServer->vtbl->SetVRDEProperty(VRDxServer, VRDEPortsKey,
+ VRDEPortsValue);
+ VBOX_UTF16_FREE(VRDEPortsKey);
+ VBOX_UTF16_FREE(VRDEPortsValue);
+#endif /* VBOX_API_VERSION >= 4000 */
if (def->graphics[i]->data.rdp.replaceUser) {
- VRDPServer->vtbl->SetReuseSingleConnection(VRDPServer,
+ VRDxServer->vtbl->SetReuseSingleConnection(VRDxServer,
PR_TRUE);
DEBUG0("VRDP set to reuse single connection");
}
if (def->graphics[i]->data.rdp.multiUser) {
- VRDPServer->vtbl->SetAllowMultiConnection(VRDPServer,
+ VRDxServer->vtbl->SetAllowMultiConnection(VRDxServer,
PR_TRUE);
DEBUG0("VRDP set to allow multiple connection");
}
if (def->graphics[i]->data.rdp.listenAddr) {
+#if VBOX_API_VERSION >= 4000
+ PRUnichar *netAddressKey = NULL;
+#endif
PRUnichar *netAddressUtf16 = NULL;
VBOX_UTF8_TO_UTF16(def->graphics[i]->data.rdp.listenAddr,
&netAddressUtf16);
- VRDPServer->vtbl->SetNetAddress(VRDPServer,
+#if VBOX_API_VERSION < 4000
+ VRDxServer->vtbl->SetNetAddress(VRDxServer,
netAddressUtf16);
+#else /* VBOX_API_VERSION >= 4000 */
+ VBOX_UTF8_TO_UTF16("TCP/Address", &netAddressKey);
+ VRDxServer->vtbl->SetVRDEProperty(VRDxServer, netAddressKey,
+ netAddressUtf16);
+ VBOX_UTF16_FREE(netAddressKey);
+#endif /* VBOX_API_VERSION >= 4000 */
DEBUG("VRDP listen address is set to: %s",
def->graphics[i]->data.rdp.listenAddr);
VBOX_UTF16_FREE(netAddressUtf16);
}
- VBOX_RELEASE(VRDPServer);
+ VBOX_RELEASE(VRDxServer);
}
}
@@ -4599,7 +4745,7 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
NULL,
iid.value,
&machine);
-#else /* VBOX_API_VERSION >= 3002 */
+#elif VBOX_API_VERSION < 4000 /* 3002 <= VBOX_API_VERSION < 4000 */
rc = data->vboxObj->vtbl->CreateMachine(data->vboxObj,
machineNameUtf16,
NULL,
@@ -4607,7 +4753,15 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
iid.value,
override,
&machine);
-#endif /* VBOX_API_VERSION >= 3002 */
+#else /* VBOX_API_VERSION >= 4000 */
+ rc = data->vboxObj->vtbl->CreateMachine(data->vboxObj,
+ NULL,
+ machineNameUtf16,
+ NULL,
+ iid.value,
+ override,
+ &machine);
+#endif /* VBOX_API_VERSION >= 4000 */
VBOX_UTF16_FREE(machineNameUtf16);
if (NS_FAILED(rc)) {
@@ -4688,7 +4842,7 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
* you can make changes to the machine setting
*/
machine->vtbl->GetId(machine, &mchiid.value);
- data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, mchiid.value);
+ VBOX_SESSION_OPEN(mchiid.value, machine);
data->vboxSession->vtbl->GetMachine(data->vboxSession, &machine);
vboxSetBootDeviceOrder(def, data, machine);
@@ -4705,12 +4859,11 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
* session. also free up the mchiid variable used.
*/
rc = machine->vtbl->SaveSettings(machine);
- data->vboxSession->vtbl->Close(data->vboxSession);
+ VBOX_SESSION_CLOSE();
vboxIIDUnalloc(&mchiid);
ret = virGetDomain(conn, def->name, def->uuid);
VBOX_RELEASE(machine);
- machine = NULL;
vboxIIDUnalloc(&iid);
virDomainDefFree(def);
@@ -4724,18 +4877,27 @@ cleanup:
return NULL;
}
-static int vboxDomainUndefine(virDomainPtr dom) {
+static int
+vboxDomainUndefine(virDomainPtr dom)
+{
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
vboxIID iid = VBOX_IID_INITIALIZER;
nsresult rc;
+#if VBOX_API_VERSION >= 4000
+ vboxArray media = VBOX_ARRAY_INITIALIZER;
+#endif
vboxIIDFromUUID(&iid, dom->uuid);
+#if VBOX_API_VERSION < 4000
/* Block for checking if HDD's are attched to VM.
* considering just IDE bus for now. Also skipped
* chanel=1 and device=0 (Secondary Master) as currenlty
- * it is allocated to CD/DVD Drive bt default
+ * it is allocated to CD/DVD Drive by default.
+ *
+ * Only do this for VirtualBox 3.x and before. Since
+ * VirtualBox 4.0 the Unregister method can do this for use.
*/
{
PRUnichar *hddcnameUtf16 = NULL;
@@ -4745,17 +4907,17 @@ static int vboxDomainUndefine(virDomainPtr dom) {
VIR_FREE(hddcname);
/* Open a Session for the machine */
- rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid.value);
+ rc = VBOX_SESSION_OPEN(iid.value, machine);
if (NS_SUCCEEDED(rc)) {
rc = data->vboxSession->vtbl->GetMachine(data->vboxSession, &machine);
if (NS_SUCCEEDED(rc) && machine) {
-#if VBOX_API_VERSION < 3001
+# if VBOX_API_VERSION < 3001
/* Disconnect all the drives if present */
machine->vtbl->DetachHardDisk(machine, hddcnameUtf16, 0, 0);
machine->vtbl->DetachHardDisk(machine, hddcnameUtf16, 0, 1);
machine->vtbl->DetachHardDisk(machine, hddcnameUtf16, 1, 1);
-#else /* VBOX_API_VERSION >= 3001 */
+# else /* VBOX_API_VERSION >= 3001 */
/* get all the controller first, then the attachments and
* remove them all so that the machine can be undefined
*/
@@ -4774,9 +4936,9 @@ static int vboxDomainUndefine(virDomainPtr dom) {
continue;
strCtl->vtbl->GetName(strCtl, &strCtlName);
- vboxArrayGetWithArg(&mediumAttachments, machine,
- machine->vtbl->GetMediumAttachmentsOfController,
- strCtlName);
+ vboxArrayGetWithPtrArg(&mediumAttachments, machine,
+ machine->vtbl->GetMediumAttachmentsOfController,
+ strCtlName);
for (j = 0; j < mediumAttachments.count; j++) {
IMediumAttachment *medAtt = mediumAttachments.items[j];
@@ -4804,26 +4966,70 @@ static int vboxDomainUndefine(virDomainPtr dom) {
}
vboxArrayRelease(&storageControllers);
-#endif /* VBOX_API_VERSION >= 3001 */
+# endif /* VBOX_API_VERSION >= 3001 */
machine->vtbl->SaveSettings(machine);
}
- data->vboxSession->vtbl->Close(data->vboxSession);
+ VBOX_SESSION_CLOSE();
}
VBOX_UTF16_FREE(hddcnameUtf16);
}
+#endif
+#if VBOX_API_VERSION < 4000
rc = data->vboxObj->vtbl->UnregisterMachine(data->vboxObj, iid.value, &machine);
+#else /* VBOX_API_VERSION >= 4000 */
+ rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
+ if (NS_FAILED(rc)) {
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
+ _("no domain with matching uuid"));
+ return -1;
+ }
+
+ /* We're not interested in the array returned by the Unregister method,
+ * but in the side effect of unregistering the virtual machine. In order
+ * to call the Unregister method correctly we need to use the vboxArray
+ * wrapper here. */
+ rc = vboxArrayGetWithUintArg(&media, machine, machine->vtbl->Unregister,
+ CleanupMode_DetachAllReturnNone);
+#endif /* VBOX_API_VERSION >= 4000 */
DEBUGIID("UUID of machine being undefined", iid.value);
- if (NS_SUCCEEDED(rc) && machine){
+ if (NS_SUCCEEDED(rc)) {
+#if VBOX_API_VERSION < 4000
machine->vtbl->DeleteSettings(machine);
+#else /* VBOX_API_VERSION >= 4000 */
+ IProgress *progress = NULL;
+
+ /* The IMachine Delete method takes an array of IMedium items to be
+ * deleted along with the virtual machine. We just want to pass an
+ * empty array. But instead of adding a full vboxArraySetWithReturn to
+ * the glue layer (in order to handle the required signature of the
+ * Delete method) we use a local solution here. */
+# ifdef WIN32
+ SAFEARRAY *safeArray = NULL;
+ typedef HRESULT __stdcall (*IMachine_Delete)(IMachine *self,
+ SAFEARRAY **media,
+ IProgress **progress);
+
+ ((IMachine_Delete)machine->vtbl->Delete)(machine, &safeArray, &progress);
+# else
+ machine->vtbl->Delete(machine, 0, NULL, &progress);
+# endif
+ if (progress != NULL) {
+ progress->vtbl->WaitForCompletion(progress, -1);
+ VBOX_RELEASE(progress);
+ }
+#endif /* VBOX_API_VERSION >= 4000 */
ret = 0;
} else {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not delete the domain, rc=%08x"), (unsigned)rc);
}
+#if VBOX_API_VERSION >= 4000
+ vboxArrayUnalloc(&media);
+#endif
vboxIIDUnalloc(&iid);
VBOX_RELEASE(machine);
@@ -4861,7 +5067,7 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
}
vboxIIDFromUUID(&iid, dom->uuid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
+ rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
@@ -4873,9 +5079,9 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
if ((state == MachineState_Running) ||
(state == MachineState_Paused)) {
- rc = data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
+ rc = VBOX_SESSION_OPEN_EXISTING(iid.value, machine);
} else {
- rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid.value);
+ rc = VBOX_SESSION_OPEN(iid.value, machine);
}
if (NS_SUCCEEDED(rc)) {
rc = data->vboxSession->vtbl->GetMachine(data->vboxSession, &machine);
@@ -4996,7 +5202,7 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
machine->vtbl->SaveSettings(machine);
VBOX_RELEASE(machine);
}
- data->vboxSession->vtbl->Close(data->vboxSession);
+ VBOX_SESSION_CLOSE();
}
}
@@ -5066,7 +5272,7 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) {
}
vboxIIDFromUUID(&iid, dom->uuid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
+ rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
@@ -5078,9 +5284,9 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) {
if ((state == MachineState_Running) ||
(state == MachineState_Paused)) {
- rc = data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
+ rc = VBOX_SESSION_OPEN_EXISTING(iid.value, machine);
} else {
- rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid.value);
+ rc = VBOX_SESSION_OPEN(iid.value, machine);
}
if (NS_SUCCEEDED(rc)) {
@@ -5150,7 +5356,7 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) {
machine->vtbl->SaveSettings(machine);
VBOX_RELEASE(machine);
}
- data->vboxSession->vtbl->Close(data->vboxSession);
+ VBOX_SESSION_CLOSE();
}
}
@@ -5200,7 +5406,11 @@ vboxDomainSnapshotGetAll(virDomainPtr dom,
goto error;
}
+#if VBOX_API_VERSION < 4000
rc = machine->vtbl->GetSnapshot(machine, empty.value, list);
+#else /* VBOX_API_VERSION >= 4000 */
+ rc = machine->vtbl->FindSnapshot(machine, empty.value, list);
+#endif /* VBOX_API_VERSION >= 4000 */
if (NS_FAILED(rc) || !list[0]) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not get root snapshot for domain %s"),
@@ -5338,7 +5548,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
goto cleanup;
vboxIIDFromUUID(&domiid, dom->uuid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid.value, &machine);
+ rc = VBOX_OBJECT_GET_MACHINE(domiid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
@@ -5354,14 +5564,11 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
if ((state >= MachineState_FirstOnline)
&& (state <= MachineState_LastOnline)) {
- rc = data->vboxObj->vtbl->OpenExistingSession(data->vboxObj,
- data->vboxSession,
- domiid.value);
+ rc = VBOX_SESSION_OPEN_EXISTING(domiid.value, machine);
} else {
- rc = data->vboxObj->vtbl->OpenSession(data->vboxObj,
- data->vboxSession,
- domiid.value);
+ rc = VBOX_SESSION_OPEN(domiid.value, machine);
}
+
if (NS_SUCCEEDED(rc))
rc = data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (NS_FAILED(rc)) {
@@ -5415,7 +5622,7 @@ cleanup:
VBOX_UTF16_FREE(description);
VBOX_UTF16_FREE(name);
VBOX_RELEASE(console);
- data->vboxSession->vtbl->Close(data->vboxSession);
+ VBOX_SESSION_CLOSE();
VBOX_RELEASE(machine);
vboxIIDUnalloc(&domiid);
virDomainSnapshotDefFree(def);
@@ -5443,7 +5650,7 @@ vboxDomainSnapshotDumpXML(virDomainSnapshotPtr snapshot,
virCheckFlags(0, NULL);
vboxIIDFromUUID(&domiid, dom->uuid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid.value, &machine);
+ rc = VBOX_OBJECT_GET_MACHINE(domiid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
@@ -5547,7 +5754,7 @@ vboxDomainSnapshotNum(virDomainPtr dom,
virCheckFlags(0, -1);
vboxIIDFromUUID(&iid, dom->uuid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
+ rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
@@ -5587,7 +5794,7 @@ vboxDomainSnapshotListNames(virDomainPtr dom,
virCheckFlags(0, -1);
vboxIIDFromUUID(&iid, dom->uuid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
+ rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
@@ -5650,7 +5857,7 @@ vboxDomainSnapshotLookupByName(virDomainPtr dom,
virCheckFlags(0, NULL);
vboxIIDFromUUID(&iid, dom->uuid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
+ rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
@@ -5682,7 +5889,7 @@ vboxDomainHasCurrentSnapshot(virDomainPtr dom,
virCheckFlags(0, -1);
vboxIIDFromUUID(&iid, dom->uuid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
+ rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
@@ -5722,7 +5929,7 @@ vboxDomainSnapshotCurrent(virDomainPtr dom,
virCheckFlags(0, NULL);
vboxIIDFromUUID(&iid, dom->uuid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
+ rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
@@ -5831,8 +6038,7 @@ vboxDomainSnapshotRestore(virDomainPtr dom,
goto cleanup;
}
- rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession,
- domiid.value);
+ rc = VBOX_SESSION_OPEN(domiid.value, machine);
if (NS_SUCCEEDED(rc))
rc = data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (NS_FAILED(rc)) {
@@ -5868,7 +6074,7 @@ vboxDomainSnapshotRestore(virDomainPtr dom,
cleanup:
VBOX_RELEASE(progress);
VBOX_RELEASE(console);
- data->vboxSession->vtbl->Close(data->vboxSession);
+ VBOX_SESSION_CLOSE();
vboxIIDUnalloc(&domiid);
return ret;
}
@@ -5891,7 +6097,7 @@ vboxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
virCheckFlags(0, -1);
vboxIIDFromUUID(&domiid, dom->uuid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid.value, &machine);
+ rc = VBOX_OBJECT_GET_MACHINE(domiid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
@@ -6048,7 +6254,7 @@ vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN, -1);
vboxIIDFromUUID(&domiid, dom->uuid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid.value, &machine);
+ rc = VBOX_OBJECT_GET_MACHINE(domiid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
@@ -6073,8 +6279,7 @@ vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
goto cleanup;
}
- rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession,
- domiid.value);
+ rc = VBOX_SESSION_OPEN(domiid.value, machine);
if (NS_SUCCEEDED(rc))
rc = data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (NS_FAILED(rc)) {
@@ -6093,13 +6298,13 @@ cleanup:
VBOX_RELEASE(console);
VBOX_RELEASE(snap);
vboxIIDUnalloc(&domiid);
- data->vboxSession->vtbl->Close(data->vboxSession);
+ VBOX_SESSION_CLOSE();
return ret;
}
-#if VBOX_API_VERSION == 2002
+#if VBOX_API_VERSION == 2002 || VBOX_API_VERSION == 4000
/* No Callback support for VirtualBox 2.2.* series */
-#else /* !(VBOX_API_VERSION == 2002) */
+#else /* !(VBOX_API_VERSION == 2002) && !(VBOX_API_VERSION == 4000) */
/* Functions needed for Callbacks */
static nsresult PR_COM_METHOD
@@ -6654,7 +6859,7 @@ static int vboxDomainEventDeregisterAny(virConnectPtr conn,
return ret;
}
-#endif /* !(VBOX_API_VERSION == 2002) */
+#endif /* !(VBOX_API_VERSION == 2002) && !(VBOX_API_VERSION == 4000) */
/**
* The Network Functions here on
@@ -7705,7 +7910,12 @@ static virStorageVolPtr vboxStorageVolLookupByKey(virConnectPtr conn, const char
}
vboxIIDFromUUID(&hddIID, uuid);
+#if VBOX_API_VERSION < 4000
rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID.value, &hardDisk);
+#else /* VBOX_API_VERSION >= 4000 */
+ rc = data->vboxObj->vtbl->FindMedium(data->vboxObj, hddIID.value,
+ DeviceType_HardDisk, &hardDisk);
+#endif /* VBOX_API_VERSION >= 4000 */
if (NS_SUCCEEDED(rc)) {
PRUint32 hddstate;
@@ -7756,7 +7966,12 @@ static virStorageVolPtr vboxStorageVolLookupByPath(virConnectPtr conn, const cha
if (!hddPathUtf16)
return ret;
+#if VBOX_API_VERSION < 4000
rc = data->vboxObj->vtbl->FindHardDisk(data->vboxObj, hddPathUtf16, &hardDisk);
+#else /* VBOX_API_VERSION >= 4000 */
+ rc = data->vboxObj->vtbl->FindMedium(data->vboxObj, hddPathUtf16,
+ DeviceType_HardDisk, &hardDisk);
+#endif /* VBOX_API_VERSION >= 4000 */
if (NS_SUCCEEDED(rc)) {
PRUint32 hddstate;
@@ -7920,7 +8135,12 @@ static int vboxStorageVolDelete(virStorageVolPtr vol,
}
vboxIIDFromUUID(&hddIID, uuid);
+#if VBOX_API_VERSION < 4000
rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID.value, &hardDisk);
+#else /* VBOX_API_VERSION >= 4000 */
+ rc = data->vboxObj->vtbl->FindMedium(data->vboxObj, hddIID.value,
+ DeviceType_HardDisk, &hardDisk);
+#endif /* VBOX_API_VERSION >= 4000 */
if (NS_SUCCEEDED(rc)) {
PRUint32 hddstate;
@@ -7955,7 +8175,17 @@ static int vboxStorageVolDelete(virStorageVolPtr vol,
vboxIIDFromArrayItem(&machineId, &machineIds, i);
- rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, machineId.value);
+#if VBOX_API_VERSION >= 4000
+ rc = VBOX_OBJECT_GET_MACHINE(machineId.value, &machine);
+ if (NS_FAILED(rc)) {
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
+ _("no domain with matching uuid"));
+ break;
+ }
+#endif
+
+ rc = VBOX_SESSION_OPEN(machineId.value, machine);
+
if (NS_SUCCEEDED(rc)) {
rc = data->vboxSession->vtbl->GetMachine(data->vboxSession, &machine);
@@ -8027,7 +8257,7 @@ static int vboxStorageVolDelete(virStorageVolPtr vol,
vboxArrayRelease(&hddAttachments);
VBOX_RELEASE(machine);
}
- data->vboxSession->vtbl->Close(data->vboxSession);
+ VBOX_SESSION_CLOSE();
}
vboxIIDUnalloc(&machineId);
@@ -8074,19 +8304,33 @@ static int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info
}
vboxIIDFromUUID(&hddIID, uuid);
+#if VBOX_API_VERSION < 4000
rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID.value, &hardDisk);
+#else /* VBOX_API_VERSION >= 4000 */
+ rc = data->vboxObj->vtbl->FindMedium(data->vboxObj, hddIID.value,
+ DeviceType_HardDisk, &hardDisk);
+#endif /* VBOX_API_VERSION >= 4000 */
if (NS_SUCCEEDED(rc)) {
PRUint32 hddstate;
VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetState, &hddstate);
if (hddstate != MediaState_Inaccessible) {
+#if VBOX_API_VERSION < 4000
PRUint64 hddLogicalSize;
PRUint64 hddActualSize;
+#else /* VBOX_API_VERSION >= 4000 */
+ PRInt64 hddLogicalSize;
+ PRInt64 hddActualSize;
+#endif /* VBOX_API_VERSION >= 4000 */
info->type = VIR_STORAGE_VOL_FILE;
hardDisk->vtbl->GetLogicalSize(hardDisk, &hddLogicalSize);
+#if VBOX_API_VERSION < 4000
info->capacity = hddLogicalSize * 1024 * 1024; /* MB => Bytes */
+#else /* VBOX_API_VERSION >= 4000 */
+ info->capacity = hddLogicalSize;
+#endif /* VBOX_API_VERSION >= 4000 */
VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetSize, &hddActualSize);
info->allocation = hddActualSize;
@@ -8127,15 +8371,25 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags A
}
vboxIIDFromUUID(&hddIID, uuid);
+#if VBOX_API_VERSION < 4000
rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID.value, &hardDisk);
+#else /* VBOX_API_VERSION >= 4000 */
+ rc = data->vboxObj->vtbl->FindMedium(data->vboxObj, hddIID.value,
+ DeviceType_HardDisk, &hardDisk);
+#endif /* VBOX_API_VERSION >= 4000 */
if (NS_SUCCEEDED(rc)) {
PRUint32 hddstate;
VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetState, &hddstate);
if (NS_SUCCEEDED(rc) && hddstate != MediaState_Inaccessible) {
PRUnichar *hddFormatUtf16 = NULL;
+#if VBOX_API_VERSION < 4000
PRUint64 hddLogicalSize;
PRUint64 hddActualSize;
+#else /* VBOX_API_VERSION >= 4000 */
+ PRInt64 hddLogicalSize;
+ PRInt64 hddActualSize;
+#endif /* VBOX_API_VERSION >= 4000 */
/* since there is currently one default pool now
* and virStorageVolDefFormat() just checks it type
@@ -8147,9 +8401,13 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags A
defOk = 1;
rc = hardDisk->vtbl->GetLogicalSize(hardDisk, &hddLogicalSize);
- if (NS_SUCCEEDED(rc) && defOk)
+ if (NS_SUCCEEDED(rc) && defOk) {
+#if VBOX_API_VERSION < 4000
def.capacity = hddLogicalSize * 1024 * 1024; /* MB => Bytes */
- else
+#else /* VBOX_API_VERSION >= 4000 */
+ def.capacity = hddLogicalSize;
+#endif /* VBOX_API_VERSION >= 4000 */
+ } else
defOk = 0;
rc = VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetSize, &hddActualSize);
@@ -8220,7 +8478,12 @@ static char *vboxStorageVolGetPath(virStorageVolPtr vol) {
}
vboxIIDFromUUID(&hddIID, uuid);
+#if VBOX_API_VERSION < 4000
rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID.value, &hardDisk);
+#else /* VBOX_API_VERSION >= 4000 */
+ rc = data->vboxObj->vtbl->FindMedium(data->vboxObj, hddIID.value,
+ DeviceType_HardDisk, &hardDisk);
+#endif /* VBOX_API_VERSION >= 4000 */
if (NS_SUCCEEDED(rc)) {
PRUint32 hddstate;
@@ -8330,7 +8593,7 @@ virDriver NAME(Driver) = {
NULL, /* domainGetBlockInfo */
nodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
nodeGetFreeMemory, /* getFreeMemory */
-#if VBOX_API_VERSION == 2002
+#if VBOX_API_VERSION == 2002 || VBOX_API_VERSION == 4000
NULL, /* domainEventRegister */
NULL, /* domainEventDeregister */
#else
@@ -8353,7 +8616,7 @@ virDriver NAME(Driver) = {
NULL, /* domainGetJobInfo */
NULL, /* domainAbortJob */
NULL, /* domainMigrateSetMaxDowntime */
-#if VBOX_API_VERSION == 2002
+#if VBOX_API_VERSION == 2002 || VBOX_API_VERSION == 4000
NULL, /* domainEventRegisterAny */
NULL, /* domainEventDeregisterAny */
#else
--
1.7.0.4
2
2
[libvirt] [PATCH] vbox: Handle different IID representation in Version 2.2 on Windows
by Matthias Bolte 28 Dec '10
by Matthias Bolte 28 Dec '10
28 Dec '10
On Windows IID's are represented as GUID by value, instead of nsID
by reference on non-Windows platforms.
Patch the vbox_CAPI_v2_2.h header to deal with this difference.
Rewrite vboxIID abstraction that deals with the different IID
representations. Add support for the GUID representation. Also unify
the four context dependent free functions for vboxIIDs
vboxIIDUnalloc, vboxIIDFree, vboxIIDUtf8Free, vboxIIDUtf16Free
into vboxIIDUnalloc that is now safe to be called (even multiple
times) on a vboxIID independent of the source and context of the
vboxIID.
The new vboxIID is designed to be used as a stack allocated variable.
It has a value member that represents the actual IID value.
---
src/vbox/vbox_CAPI_v2_2.h | 108 +++--
src/vbox/vbox_tmpl.c | 1143 +++++++++++++++++++++------------------------
2 files changed, 582 insertions(+), 669 deletions(-)
diff --git a/src/vbox/vbox_CAPI_v2_2.h b/src/vbox/vbox_CAPI_v2_2.h
index 0543fdd..a94d2ec 100644
--- a/src/vbox/vbox_CAPI_v2_2.h
+++ b/src/vbox/vbox_CAPI_v2_2.h
@@ -57,8 +57,12 @@
# ifdef WIN32
# define PR_COM_METHOD __stdcall
+# define PR_IID_IN_TYPE GUID
+# define PR_IID_OUT_TYPE GUID *
# else
# define PR_COM_METHOD
+# define PR_IID_IN_TYPE const nsID *
+# define PR_IID_OUT_TYPE nsID **
# endif
# if defined(WIN32)
@@ -355,7 +359,7 @@ struct nsISupports_vtbl {
* instance, NS_NOINTERFACE if it is not.
* NS_ERROR_INVALID_POINTER if aInstancePtr is NULL.
*/
- nsresult PR_COM_METHOD (*QueryInterface)(nsISupports *pThis, const nsID *iid, void **resultp);
+ nsresult PR_COM_METHOD (*QueryInterface)(nsISupports *pThis, PR_IID_IN_TYPE iid, void **resultp);
/**
* Increases the reference count for this interface.
* The associated instance will not be deleted unless
@@ -1396,7 +1400,7 @@ struct IVirtualBoxErrorInfo_vtbl
nsresult PR_COM_METHOD (*GetResultCode)(IVirtualBoxErrorInfo *pThis, nsresult *resultCode);
- nsresult PR_COM_METHOD (*GetInterfaceID)(IVirtualBoxErrorInfo *pThis, nsID * *interfaceID);
+ nsresult PR_COM_METHOD (*GetInterfaceID)(IVirtualBoxErrorInfo *pThis, PR_IID_OUT_TYPE interfaceID);
nsresult PR_COM_METHOD (*GetComponent)(IVirtualBoxErrorInfo *pThis, PRUnichar * *component);
@@ -1425,18 +1429,18 @@ struct IVirtualBoxCallback_vtbl
nsresult PR_COM_METHOD (*OnMachineStateChange)(
IVirtualBoxCallback *pThis,
- const nsID * machineId,
+ PR_IID_IN_TYPE machineId,
PRUint32 state
);
nsresult PR_COM_METHOD (*OnMachineDataChange)(
IVirtualBoxCallback *pThis,
- const nsID * machineId
+ PR_IID_IN_TYPE machineId
);
nsresult PR_COM_METHOD (*OnExtraDataCanChange)(
IVirtualBoxCallback *pThis,
- const nsID * machineId,
+ PR_IID_IN_TYPE machineId,
PRUnichar * key,
PRUnichar * value,
PRUnichar * * error,
@@ -1445,51 +1449,51 @@ struct IVirtualBoxCallback_vtbl
nsresult PR_COM_METHOD (*OnExtraDataChange)(
IVirtualBoxCallback *pThis,
- const nsID * machineId,
+ PR_IID_IN_TYPE machineId,
PRUnichar * key,
PRUnichar * value
);
nsresult PR_COM_METHOD (*OnMediaRegistered)(
IVirtualBoxCallback *pThis,
- const nsID * mediaId,
+ PR_IID_IN_TYPE mediaId,
PRUint32 mediaType,
PRBool registered
);
nsresult PR_COM_METHOD (*OnMachineRegistered)(
IVirtualBoxCallback *pThis,
- const nsID * machineId,
+ PR_IID_IN_TYPE machineId,
PRBool registered
);
nsresult PR_COM_METHOD (*OnSessionStateChange)(
IVirtualBoxCallback *pThis,
- const nsID * machineId,
+ PR_IID_IN_TYPE machineId,
PRUint32 state
);
nsresult PR_COM_METHOD (*OnSnapshotTaken)(
IVirtualBoxCallback *pThis,
- const nsID * machineId,
- const nsID * snapshotId
+ PR_IID_IN_TYPE machineId,
+ PR_IID_IN_TYPE snapshotId
);
nsresult PR_COM_METHOD (*OnSnapshotDiscarded)(
IVirtualBoxCallback *pThis,
- const nsID * machineId,
- const nsID * snapshotId
+ PR_IID_IN_TYPE machineId,
+ PR_IID_IN_TYPE snapshotId
);
nsresult PR_COM_METHOD (*OnSnapshotChange)(
IVirtualBoxCallback *pThis,
- const nsID * machineId,
- const nsID * snapshotId
+ PR_IID_IN_TYPE machineId,
+ PR_IID_IN_TYPE snapshotId
);
nsresult PR_COM_METHOD (*OnGuestPropertyChange)(
IVirtualBoxCallback *pThis,
- const nsID * machineId,
+ PR_IID_IN_TYPE machineId,
PRUnichar * name,
PRUnichar * value,
PRUnichar * flags
@@ -1614,7 +1618,7 @@ struct IVirtualBox_vtbl
PRUnichar * name,
PRUnichar * osTypeId,
PRUnichar * baseFolder,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IMachine * * machine
);
@@ -1623,7 +1627,7 @@ struct IVirtualBox_vtbl
PRUnichar * name,
PRUnichar * osTypeId,
PRUnichar * settingsFile,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IMachine * * machine
);
@@ -1640,7 +1644,7 @@ struct IVirtualBox_vtbl
nsresult PR_COM_METHOD (*GetMachine)(
IVirtualBox *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IMachine * * machine
);
@@ -1652,7 +1656,7 @@ struct IVirtualBox_vtbl
nsresult PR_COM_METHOD (*UnregisterMachine)(
IVirtualBox *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IMachine * * machine
);
@@ -1677,7 +1681,7 @@ struct IVirtualBox_vtbl
nsresult PR_COM_METHOD (*GetHardDisk)(
IVirtualBox *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IHardDisk * * hardDisk
);
@@ -1690,13 +1694,13 @@ struct IVirtualBox_vtbl
nsresult PR_COM_METHOD (*OpenDVDImage)(
IVirtualBox *pThis,
PRUnichar * location,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IDVDImage * * image
);
nsresult PR_COM_METHOD (*GetDVDImage)(
IVirtualBox *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IDVDImage * * image
);
@@ -1709,13 +1713,13 @@ struct IVirtualBox_vtbl
nsresult PR_COM_METHOD (*OpenFloppyImage)(
IVirtualBox *pThis,
PRUnichar * location,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IFloppyImage * * image
);
nsresult PR_COM_METHOD (*GetFloppyImage)(
IVirtualBox *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IFloppyImage * * image
);
@@ -1765,13 +1769,13 @@ struct IVirtualBox_vtbl
nsresult PR_COM_METHOD (*OpenSession)(
IVirtualBox *pThis,
ISession * session,
- const nsID * machineId
+ PR_IID_IN_TYPE machineId
);
nsresult PR_COM_METHOD (*OpenRemoteSession)(
IVirtualBox *pThis,
ISession * session,
- const nsID * machineId,
+ PR_IID_IN_TYPE machineId,
PRUnichar * type,
PRUnichar * environment,
IProgress * * progress
@@ -1780,7 +1784,7 @@ struct IVirtualBox_vtbl
nsresult PR_COM_METHOD (*OpenExistingSession)(
IVirtualBox *pThis,
ISession * session,
- const nsID * machineId
+ PR_IID_IN_TYPE machineId
);
nsresult PR_COM_METHOD (*RegisterCallback)(
@@ -1988,12 +1992,12 @@ struct IInternalMachineControl_vtbl
nsresult PR_COM_METHOD (*CaptureUSBDevice)(
IInternalMachineControl *pThis,
- const nsID * id
+ PR_IID_IN_TYPE id
);
nsresult PR_COM_METHOD (*DetachUSBDevice)(
IInternalMachineControl *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
PRBool done
);
@@ -2044,7 +2048,7 @@ struct IInternalMachineControl_vtbl
nsresult PR_COM_METHOD (*DiscardSnapshot)(
IInternalMachineControl *pThis,
IConsole * initiator,
- const nsID * id,
+ PR_IID_IN_TYPE id,
PRUint32 * machineState,
IProgress * * progress
);
@@ -2174,7 +2178,7 @@ struct IMachine_vtbl
nsresult PR_COM_METHOD (*GetDescription)(IMachine *pThis, PRUnichar * *description);
nsresult PR_COM_METHOD (*SetDescription)(IMachine *pThis, PRUnichar * description);
- nsresult PR_COM_METHOD (*GetId)(IMachine *pThis, nsID * *id);
+ nsresult PR_COM_METHOD (*GetId)(IMachine *pThis, PR_IID_OUT_TYPE id);
nsresult PR_COM_METHOD (*GetOSTypeId)(IMachine *pThis, PRUnichar * *OSTypeId);
nsresult PR_COM_METHOD (*SetOSTypeId)(IMachine *pThis, PRUnichar * OSTypeId);
@@ -2282,7 +2286,7 @@ struct IMachine_vtbl
nsresult PR_COM_METHOD (*AttachHardDisk)(
IMachine *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
PRUnichar * name,
PRInt32 controllerPort,
PRInt32 device
@@ -2384,7 +2388,7 @@ struct IMachine_vtbl
nsresult PR_COM_METHOD (*GetSnapshot)(
IMachine *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
ISnapshot * * snapshot
);
@@ -2396,7 +2400,7 @@ struct IMachine_vtbl
nsresult PR_COM_METHOD (*SetCurrentSnapshot)(
IMachine *pThis,
- const nsID * id
+ PR_IID_IN_TYPE id
);
nsresult PR_COM_METHOD (*CreateSharedFolder)(
@@ -2716,12 +2720,12 @@ struct IConsole_vtbl
nsresult PR_COM_METHOD (*AttachUSBDevice)(
IConsole *pThis,
- const nsID * id
+ PR_IID_IN_TYPE id
);
nsresult PR_COM_METHOD (*DetachUSBDevice)(
IConsole *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IUSBDevice * * device
);
@@ -2733,7 +2737,7 @@ struct IConsole_vtbl
nsresult PR_COM_METHOD (*FindUSBDeviceById)(
IConsole *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IUSBDevice * * device
);
@@ -2758,7 +2762,7 @@ struct IConsole_vtbl
nsresult PR_COM_METHOD (*DiscardSnapshot)(
IConsole *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IProgress * * progress
);
@@ -2853,7 +2857,7 @@ struct IHostNetworkInterface_vtbl
nsresult PR_COM_METHOD (*GetName)(IHostNetworkInterface *pThis, PRUnichar * *name);
- nsresult PR_COM_METHOD (*GetId)(IHostNetworkInterface *pThis, nsID * *id);
+ nsresult PR_COM_METHOD (*GetId)(IHostNetworkInterface *pThis, PR_IID_OUT_TYPE id);
nsresult PR_COM_METHOD (*GetNetworkName)(IHostNetworkInterface *pThis, PRUnichar * *networkName);
@@ -2992,7 +2996,7 @@ struct IHost_vtbl
nsresult PR_COM_METHOD (*FindHostNetworkInterfaceById)(
IHost *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IHostNetworkInterface * * networkInterface
);
@@ -3005,7 +3009,7 @@ struct IHost_vtbl
nsresult PR_COM_METHOD (*FindUSBDeviceById)(
IHost *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IHostUSBDevice * * device
);
@@ -3189,7 +3193,7 @@ struct IProgress_vtbl
{
struct nsISupports_vtbl nsisupports;
- nsresult PR_COM_METHOD (*GetId)(IProgress *pThis, nsID * *id);
+ nsresult PR_COM_METHOD (*GetId)(IProgress *pThis, PR_IID_OUT_TYPE id);
nsresult PR_COM_METHOD (*GetDescription)(IProgress *pThis, PRUnichar * *description);
@@ -3249,7 +3253,7 @@ struct ISnapshot_vtbl
{
struct nsISupports_vtbl nsisupports;
- nsresult PR_COM_METHOD (*GetId)(ISnapshot *pThis, nsID * *id);
+ nsresult PR_COM_METHOD (*GetId)(ISnapshot *pThis, PR_IID_OUT_TYPE id);
nsresult PR_COM_METHOD (*GetName)(ISnapshot *pThis, PRUnichar * *name);
nsresult PR_COM_METHOD (*SetName)(ISnapshot *pThis, PRUnichar * name);
@@ -3286,7 +3290,7 @@ struct IMedium_vtbl
{
struct nsISupports_vtbl nsisupports;
- nsresult PR_COM_METHOD (*GetId)(IMedium *pThis, nsID * *id);
+ nsresult PR_COM_METHOD (*GetId)(IMedium *pThis, PR_IID_OUT_TYPE id);
nsresult PR_COM_METHOD (*GetDescription)(IMedium *pThis, PRUnichar * *description);
nsresult PR_COM_METHOD (*SetDescription)(IMedium *pThis, PRUnichar * description);
@@ -3302,11 +3306,11 @@ struct IMedium_vtbl
nsresult PR_COM_METHOD (*GetLastAccessError)(IMedium *pThis, PRUnichar * *lastAccessError);
- nsresult PR_COM_METHOD (*GetMachineIds)(IMedium *pThis, PRUint32 *machineIdsSize, nsID * **machineIds);
+ nsresult PR_COM_METHOD (*GetMachineIds)(IMedium *pThis, PRUint32 *machineIdsSize, PR_IID_OUT_TYPE *machineIds);
nsresult PR_COM_METHOD (*GetSnapshotIds)(
IMedium *pThis,
- const nsID * machineId,
+ PR_IID_IN_TYPE machineId,
PRUint32 *snapshotIdsSize,
nsID *** snapshotIds
);
@@ -3447,7 +3451,7 @@ struct IHardDisk_vtbl
nsresult PR_COM_METHOD (*MergeTo)(
IHardDisk *pThis,
- const nsID * targetId,
+ PR_IID_IN_TYPE targetId,
IProgress * * progress
);
@@ -3574,7 +3578,7 @@ struct IDVDDrive_vtbl
nsresult PR_COM_METHOD (*MountImage)(
IDVDDrive *pThis,
- const nsID * imageId
+ PR_IID_IN_TYPE imageId
);
nsresult PR_COM_METHOD (*CaptureHostDrive)(
@@ -3620,7 +3624,7 @@ struct IFloppyDrive_vtbl
nsresult PR_COM_METHOD (*MountImage)(
IFloppyDrive *pThis,
- const nsID * imageId
+ PR_IID_IN_TYPE imageId
);
nsresult PR_COM_METHOD (*CaptureHostDrive)(
@@ -4221,7 +4225,7 @@ struct IUSBDevice_vtbl
{
struct nsISupports_vtbl nsisupports;
- nsresult PR_COM_METHOD (*GetId)(IUSBDevice *pThis, nsID * *id);
+ nsresult PR_COM_METHOD (*GetId)(IUSBDevice *pThis, PR_IID_OUT_TYPE id);
nsresult PR_COM_METHOD (*GetVendorId)(IUSBDevice *pThis, PRUint16 *vendorId);
@@ -4523,7 +4527,7 @@ struct IInternalSessionControl_vtbl
nsresult PR_COM_METHOD (*OnUSBDeviceDetach)(
IInternalSessionControl *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IVirtualBoxErrorInfo * error
);
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 728c501..aa1afa9 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -220,14 +220,6 @@ static void vboxDriverUnlock(vboxGlobalData *data) {
#if VBOX_API_VERSION == 2002
-# define vboxIIDFromUUID(uuid, iid) nsIDFromChar((iid), (uuid))
-# define vboxIIDToUUID(uuid, iid) nsIDtoChar((uuid), (iid))
-# define vboxIIDUnalloc(iid) data->pFuncs->pfnComUnallocMem(iid)
-# define vboxIIDFree(iid) VIR_FREE(iid)
-# define vboxIIDUtf8Free(iid) VIR_FREE(iid)
-# define vboxIIDUtf16Free(iid) VIR_FREE(iid)
-# define DEBUGIID(msg, iid) DEBUGUUID(msg, iid)
-
static void nsIDtoChar(unsigned char *uuid, const nsID *iid) {
char uuidstrsrc[VIR_UUID_STRING_BUFLEN];
char uuidstrdst[VIR_UUID_STRING_BUFLEN];
@@ -308,107 +300,229 @@ static void nsIDFromChar(nsID *iid, const unsigned char *uuid) {
memcpy(iid, uuidinterim, VIR_UUID_BUFLEN);
}
-typedef nsID vboxIID;
+# ifdef WIN32
-static bool vboxIIDEqual(vboxIID *firstIID, vboxIID *secondIID) {
- if (memcmp(firstIID, secondIID, sizeof(firstIID)) == 0)
- return true;
- else
- return false;
+typedef struct _vboxIID_v2_x_WIN32 vboxIID;
+typedef struct _vboxIID_v2_x_WIN32 vboxIID_v2_x_WIN32;
+
+struct _vboxIID_v2_x_WIN32 {
+ /* IID is represented by a GUID value. */
+ GUID value;
+};
+
+# define VBOX_IID_INITIALIZER { { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } } }
+
+static void
+vboxIIDUnalloc_v2_x_WIN32(vboxGlobalData *data ATTRIBUTE_UNUSED,
+ vboxIID_v2_x_WIN32 *iid ATTRIBUTE_UNUSED)
+{
+ /* Nothing to free */
}
-static void vboxIIDtoUtf8(vboxIID *iid, char **uuidstr) {
- unsigned char hddUUID[VIR_UUID_BUFLEN];
+static void
+vboxIIDToUUID_v2_x_WIN32(vboxIID_v2_x_WIN32 *iid, unsigned char *uuid)
+{
+ nsIDtoChar(uuid, (nsID *)&iid->value);
+}
- if (VIR_ALLOC_N(*uuidstr, VIR_UUID_STRING_BUFLEN) < 0) {
- virReportOOMError();
- return;
- }
+static void
+vboxIIDFromUUID_v2_x_WIN32(vboxGlobalData *data, vboxIID_v2_x_WIN32 *iid,
+ const unsigned char *uuid)
+{
+ vboxIIDUnalloc_v2_x_WIN32(data, iid);
- vboxIIDToUUID(hddUUID, iid);
- virUUIDFormat(hddUUID, *uuidstr);
+ nsIDFromChar((nsID *)&iid->value, uuid);
}
-static void vboxUtf8toIID(char *uuidstr, vboxIID **iid) {
- unsigned char hddUUID[VIR_UUID_BUFLEN];
+static bool
+vboxIIDIsEqual_v2_x_WIN32(vboxIID_v2_x_WIN32 *iid1, vboxIID_v2_x_WIN32 *iid2)
+{
+ return memcmp(&iid1->value, &iid2->value, sizeof (GUID)) == 0;
+}
- if (VIR_ALLOC(*iid) < 0) {
- virReportOOMError();
+static void
+vboxIIDFromArrayItem_v2_x_WIN32(vboxGlobalData *data, vboxIID_v2_x_WIN32 *iid,
+ vboxArray *array, int idx)
+{
+ GUID *items = (GUID *)array->items;
+
+ vboxIIDUnalloc_v2_x_WIN32(data, iid);
+
+ memcpy(&iid->value, &items[idx], sizeof (GUID));
+}
+
+# define vboxIIDUnalloc(iid) vboxIIDUnalloc_v2_x_WIN32(data, iid)
+# define vboxIIDToUUID(iid, uuid) vboxIIDToUUID_v2_x_WIN32(iid, uuid)
+# define vboxIIDFromUUID(iid, uuid) vboxIIDFromUUID_v2_x_WIN32(data, iid, uuid)
+# define vboxIIDIsEqual(iid1, iid2) vboxIIDIsEqual_v2_x_WIN32(iid1, iid2)
+# define vboxIIDFromArrayItem(iid, array, idx) \
+ vboxIIDFromArrayItem_v2_x_WIN32(data, iid, array, idx)
+# define DEBUGIID(msg, iid) DEBUGUUID(msg, (nsID *)&(iid))
+
+# else /* !WIN32 */
+
+typedef struct _vboxIID_v2_x vboxIID;
+typedef struct _vboxIID_v2_x vboxIID_v2_x;
+
+struct _vboxIID_v2_x {
+ /* IID is represented by a pointer to a nsID. */
+ nsID *value;
+
+ /* backing is used in cases where we need to create or copy an IID.
+ * We cannot allocate memory that can be freed by ComUnallocMem.
+ * Therefore, we use this stack allocated nsID instead. */
+ nsID backing;
+};
+
+# define VBOX_IID_INITIALIZER { NULL, { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } } }
+
+static void
+vboxIIDUnalloc_v2_x(vboxGlobalData *data, vboxIID_v2_x *iid)
+{
+ if (iid->value == NULL) {
return;
}
- virUUIDParse(uuidstr, hddUUID);
- vboxIIDFromUUID(hddUUID, *iid);
+ if (iid->value != &iid->backing) {
+ data->pFuncs->pfnComUnallocMem(iid->value);
+ }
+
+ iid->value = NULL;
}
+static void
+vboxIIDToUUID_v2_x(vboxIID_v2_x *iid, unsigned char *uuid)
+{
+ nsIDtoChar(uuid, iid->value);
+}
+
+static void
+vboxIIDFromUUID_v2_x(vboxGlobalData *data, vboxIID_v2_x *iid,
+ const unsigned char *uuid)
+{
+ vboxIIDUnalloc_v2_x(data, iid);
+
+ iid->value = &iid->backing;
+
+ nsIDFromChar(iid->value, uuid);
+}
+
+static bool
+vboxIIDIsEqual_v2_x(vboxIID_v2_x *iid1, vboxIID_v2_x *iid2)
+{
+ return memcmp(iid1->value, iid2->value, sizeof (nsID)) == 0;
+}
+
+static void
+vboxIIDFromArrayItem_v2_x(vboxGlobalData *data, vboxIID_v2_x *iid,
+ vboxArray *array, int idx)
+{
+ vboxIIDUnalloc_v2_x(data, iid);
+
+ iid->value = &iid->backing;
+
+ memcpy(iid->value, array->items[idx], sizeof (nsID));
+}
+
+# define vboxIIDUnalloc(iid) vboxIIDUnalloc_v2_x(data, iid)
+# define vboxIIDToUUID(iid, uuid) vboxIIDToUUID_v2_x(iid, uuid)
+# define vboxIIDFromUUID(iid, uuid) vboxIIDFromUUID_v2_x(data, iid, uuid)
+# define vboxIIDIsEqual(iid1, iid2) vboxIIDIsEqual_v2_x(iid1, iid2)
+# define vboxIIDFromArrayItem(iid, array, idx) \
+ vboxIIDFromArrayItem_v2_x(data, iid, array, idx)
+# define DEBUGIID(msg, iid) DEBUGUUID(msg, iid)
+
+# endif /* !WIN32 */
+
#else /* VBOX_API_VERSION != 2002 */
-# define vboxIIDFromUUID(uuid, iid)\
-{\
- char vboxIIDUtf8[VIR_UUID_STRING_BUFLEN];\
-\
- virUUIDFormat((uuid), vboxIIDUtf8);\
- data->pFuncs->pfnUtf8ToUtf16(vboxIIDUtf8, (&(iid)));\
+typedef struct _vboxIID_v3_x vboxIID;
+typedef struct _vboxIID_v3_x vboxIID_v3_x;
+
+struct _vboxIID_v3_x {
+ /* IID is represented by a UTF-16 encoded UUID in string form. */
+ PRUnichar *value;
+
+ /* owner indicates if we own the value and need to free it. */
+ bool owner;
+};
+
+# define VBOX_IID_INITIALIZER { NULL, true }
+
+static void
+vboxIIDUnalloc_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid)
+{
+ if (iid->value != NULL && iid->owner) {
+ data->pFuncs->pfnUtf16Free(iid->value);
+ }
+
+ iid->value = NULL;
+ iid->owner = true;
}
-# define vboxIIDToUUID(uuid, iid)\
-{\
- char *vboxIIDUtf8 = NULL;\
- data->pFuncs->pfnUtf16ToUtf8((iid), &vboxIIDUtf8);\
- virUUIDParse(vboxIIDUtf8, (uuid));\
- data->pFuncs->pfnUtf8Free(vboxIIDUtf8);\
+static void
+vboxIIDToUUID_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid,
+ unsigned char *uuid)
+{
+ char *utf8 = NULL;
+
+ data->pFuncs->pfnUtf16ToUtf8(iid->value, &utf8);
+
+ virUUIDParse(utf8, uuid);
+
+ data->pFuncs->pfnUtf8Free(utf8);
}
-# define vboxIIDFree(iid) data->pFuncs->pfnUtf16Free(iid)
-# define vboxIIDUtf8Free(iid) data->pFuncs->pfnUtf8Free(iid)
-# define vboxIIDUtf16Free(iid) data->pFuncs->pfnUtf16Free(iid)
-# define vboxIIDUnalloc(iid) data->pFuncs->pfnUtf16Free(iid)
-# define DEBUGIID(msg, strUtf16) DEBUGPRUnichar(msg, strUtf16)
+static void
+vboxIIDFromUUID_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid,
+ const unsigned char *uuid)
+{
+ char utf8[VIR_UUID_STRING_BUFLEN];
-typedef PRUnichar vboxIID;
+ vboxIIDUnalloc_v3_x(data, iid);
-static bool vboxIIDEqual(vboxIID *firstIID, vboxIID *secondIID) {
- unsigned char firstUUID[VIR_UUID_BUFLEN];
- unsigned char secondUUID[VIR_UUID_BUFLEN];
- char *firstIIDUtf8 = NULL;
- char *secondIIDUtf8 = NULL;
+ virUUIDFormat(uuid, utf8);
- if (!g_pVBoxGlobalData)
- return false;
+ data->pFuncs->pfnUtf8ToUtf16(utf8, &iid->value);
+}
- g_pVBoxGlobalData->pFuncs->pfnUtf16ToUtf8(firstIID, &firstIIDUtf8);
- g_pVBoxGlobalData->pFuncs->pfnUtf16ToUtf8(secondIID, &secondIIDUtf8);
+static bool
+vboxIIDIsEqual_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid1,
+ vboxIID_v3_x *iid2)
+{
+ unsigned char uuid1[VIR_UUID_BUFLEN];
+ unsigned char uuid2[VIR_UUID_BUFLEN];
/* Note: we can't directly compare the utf8 strings here
* cause the two UUID's may have seperators as space or '-'
* or mixture of both and we don't want to fail here by
* using direct string comparison. Here virUUIDParse() takes
- * care of these cases.
- */
+ * care of these cases. */
+ vboxIIDToUUID_v3_x(data, iid1, uuid1);
+ vboxIIDToUUID_v3_x(data, iid2, uuid2);
- virUUIDParse(firstIIDUtf8, firstUUID);
- virUUIDParse(secondIIDUtf8, secondUUID);
+ return memcmp(uuid1, uuid2, VIR_UUID_BUFLEN) == 0;
+}
- g_pVBoxGlobalData->pFuncs->pfnUtf8Free(firstIIDUtf8);
- g_pVBoxGlobalData->pFuncs->pfnUtf8Free(secondIIDUtf8);
- if (memcmp(firstUUID, secondUUID, sizeof(firstIID)) == 0)
- return true;
- else
- return false;
-}
+static void
+vboxIIDFromArrayItem_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid,
+ vboxArray *array, int idx)
+{
+ vboxIIDUnalloc_v3_x(data, iid);
-static void vboxIIDtoUtf8(vboxIID *iid, char **uuidstr) {
- g_pVBoxGlobalData->pFuncs->pfnUtf16ToUtf8(iid, uuidstr);
- if (!(*uuidstr))
- virReportOOMError();
+ iid->value = array->items[idx];
+ iid->owner = false;
}
-static void vboxUtf8toIID(char *uuidstr, vboxIID **iid) {
- g_pVBoxGlobalData->pFuncs->pfnUtf8ToUtf16(uuidstr, iid);
- if (!(*iid))
- virReportOOMError();
-}
+
+# define vboxIIDUnalloc(iid) vboxIIDUnalloc_v3_x(data, iid)
+# define vboxIIDToUUID(iid, uuid) vboxIIDToUUID_v3_x(data, iid, uuid)
+# define vboxIIDFromUUID(iid, uuid) vboxIIDFromUUID_v3_x(data, iid, uuid)
+# define vboxIIDIsEqual(iid1, iid2) vboxIIDIsEqual_v3_x(data, iid1, iid2)
+# define vboxIIDFromArrayItem(iid, array, idx) \
+ vboxIIDFromArrayItem_v3_x(data, iid, array, idx)
+# define DEBUGIID(msg, strUtf16) DEBUGPRUnichar(msg, strUtf16)
# if VBOX_API_VERSION >= 3001
@@ -1044,8 +1158,8 @@ static virDomainPtr vboxDomainCreateXML(virConnectPtr conn, const char *xml,
static virDomainPtr vboxDomainLookupByID(virConnectPtr conn, int id) {
VBOX_OBJECT_CHECK(conn, virDomainPtr, NULL);
vboxArray machines = VBOX_ARRAY_INITIALIZER;
- vboxIID *iid = NULL;
- unsigned char iidl[VIR_UUID_BUFLEN];
+ vboxIID iid = VBOX_IID_INITIALIZER;
+ unsigned char uuid[VIR_UUID_BUFLEN];
PRUint32 state;
nsresult rc;
@@ -1081,9 +1195,9 @@ static virDomainPtr vboxDomainLookupByID(virConnectPtr conn, int id) {
machine->vtbl->GetName(machine, &machineNameUtf16);
VBOX_UTF16_TO_UTF8(machineNameUtf16, &machineNameUtf8);
- machine->vtbl->GetId(machine, &iid);
- vboxIIDToUUID(iidl, iid);
- vboxIIDUnalloc(iid);
+ machine->vtbl->GetId(machine, &iid.value);
+ vboxIIDToUUID(&iid, uuid);
+ vboxIIDUnalloc(&iid);
/* get a new domain pointer from virGetDomain, if it fails
* then no need to assign the id, else assign the id, cause
@@ -1091,7 +1205,7 @@ static virDomainPtr vboxDomainLookupByID(virConnectPtr conn, int id) {
* itself, so need not worry.
*/
- ret = virGetDomain(conn, machineNameUtf8, iidl);
+ ret = virGetDomain(conn, machineNameUtf8, uuid);
if (ret)
ret->id = id + 1;
@@ -1111,10 +1225,10 @@ static virDomainPtr vboxDomainLookupByID(virConnectPtr conn, int id) {
static virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid) {
VBOX_OBJECT_CHECK(conn, virDomainPtr, NULL);
vboxArray machines = VBOX_ARRAY_INITIALIZER;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
char *machineNameUtf8 = NULL;
PRUnichar *machineNameUtf16 = NULL;
- unsigned char iidl[VIR_UUID_BUFLEN];
+ unsigned char iid_as_uuid[VIR_UUID_BUFLEN];
int i, matched = 0;
nsresult rc;
@@ -1135,13 +1249,13 @@ static virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn, const unsigned ch
machine->vtbl->GetAccessible(machine, &isAccessible);
if (isAccessible) {
- machine->vtbl->GetId(machine, &iid);
- if (!iid)
+ rc = machine->vtbl->GetId(machine, &iid.value);
+ if (NS_FAILED(rc))
continue;
- vboxIIDToUUID(iidl, iid);
- vboxIIDUnalloc(iid);
+ vboxIIDToUUID(&iid, iid_as_uuid);
+ vboxIIDUnalloc(&iid);
- if (memcmp(uuid, iidl, VIR_UUID_BUFLEN) == 0) {
+ if (memcmp(uuid, iid_as_uuid, VIR_UUID_BUFLEN) == 0) {
PRUint32 state;
@@ -1158,7 +1272,7 @@ static virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn, const unsigned ch
* itself, so need not worry.
*/
- ret = virGetDomain(conn, machineNameUtf8, iidl);
+ ret = virGetDomain(conn, machineNameUtf8, iid_as_uuid);
if ( ret
&& (state >= MachineState_FirstOnline)
&& (state <= MachineState_LastOnline) )
@@ -1181,10 +1295,10 @@ static virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn, const unsigned ch
static virDomainPtr vboxDomainLookupByName(virConnectPtr conn, const char *name) {
VBOX_OBJECT_CHECK(conn, virDomainPtr, NULL);
vboxArray machines = VBOX_ARRAY_INITIALIZER;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
char *machineNameUtf8 = NULL;
PRUnichar *machineNameUtf16 = NULL;
- unsigned char iidl[VIR_UUID_BUFLEN];
+ unsigned char uuid[VIR_UUID_BUFLEN];
int i, matched = 0;
nsresult rc;
@@ -1214,9 +1328,9 @@ static virDomainPtr vboxDomainLookupByName(virConnectPtr conn, const char *name)
matched = 1;
- machine->vtbl->GetId(machine, &iid);
- vboxIIDToUUID(iidl, iid);
- vboxIIDUnalloc(iid);
+ machine->vtbl->GetId(machine, &iid.value);
+ vboxIIDToUUID(&iid, uuid);
+ vboxIIDUnalloc(&iid);
machine->vtbl->GetState(machine, &state);
@@ -1226,7 +1340,7 @@ static virDomainPtr vboxDomainLookupByName(virConnectPtr conn, const char *name)
* itself, so need not worry.
*/
- ret = virGetDomain(conn, machineNameUtf8, iidl);
+ ret = virGetDomain(conn, machineNameUtf8, uuid);
if ( ret
&& (state >= MachineState_FirstOnline)
&& (state <= MachineState_LastOnline) )
@@ -1255,10 +1369,10 @@ static virDomainPtr vboxDomainLookupByName(virConnectPtr conn, const char *name)
static int vboxDomainIsActive(virDomainPtr dom) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
vboxArray machines = VBOX_ARRAY_INITIALIZER;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
char *machineNameUtf8 = NULL;
PRUnichar *machineNameUtf16 = NULL;
- unsigned char iidl[VIR_UUID_BUFLEN];
+ unsigned char uuid[VIR_UUID_BUFLEN];
int i, matched = 0;
nsresult rc;
@@ -1279,13 +1393,13 @@ static int vboxDomainIsActive(virDomainPtr dom) {
machine->vtbl->GetAccessible(machine, &isAccessible);
if (isAccessible) {
- machine->vtbl->GetId(machine, &iid);
- if (!iid)
+ rc = machine->vtbl->GetId(machine, &iid.value);
+ if (NS_FAILED(rc))
continue;
- vboxIIDToUUID(iidl, iid);
- vboxIIDUnalloc(iid);
+ vboxIIDToUUID(&iid, uuid);
+ vboxIIDUnalloc(&iid);
- if (memcmp(dom->uuid, iidl, VIR_UUID_BUFLEN) == 0) {
+ if (memcmp(dom->uuid, uuid, VIR_UUID_BUFLEN) == 0) {
PRUint32 state;
@@ -1330,21 +1444,14 @@ static int vboxDomainIsUpdated(virDomainPtr dom ATTRIBUTE_UNUSED) {
static int vboxDomainSuspend(virDomainPtr dom) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
IConsole *console = NULL;
PRBool isAccessible = PR_FALSE;
PRUint32 state;
nsresult rc;
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN,
_("no domain with matching id %d"), dom->id);
@@ -1360,7 +1467,7 @@ static int vboxDomainSuspend(virDomainPtr dom) {
if (state == MachineState_Running) {
/* set state pause */
- data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid);
+ data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (console) {
console->vtbl->Pause(console);
@@ -1381,29 +1488,22 @@ static int vboxDomainSuspend(virDomainPtr dom) {
cleanup:
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
static int vboxDomainResume(virDomainPtr dom) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
IConsole *console = NULL;
PRUint32 state = MachineState_Null;
nsresult rc;
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
PRBool isAccessible = PR_FALSE;
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN,
_("no domain with matching id %d"), dom->id);
@@ -1419,7 +1519,7 @@ static int vboxDomainResume(virDomainPtr dom) {
if (state == MachineState_Paused) {
/* resume the machine here */
- data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid);
+ data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (console) {
console->vtbl->Resume(console);
@@ -1440,28 +1540,21 @@ static int vboxDomainResume(virDomainPtr dom) {
cleanup:
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
static int vboxDomainShutdown(virDomainPtr dom) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
IConsole *console = NULL;
PRUint32 state = MachineState_Null;
PRBool isAccessible = PR_FALSE;
nsresult rc;
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN,
_("no domain with matching id %d"), dom->id);
@@ -1485,7 +1578,7 @@ static int vboxDomainShutdown(virDomainPtr dom) {
goto cleanup;
}
- data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid);
+ data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (console) {
console->vtbl->PowerButton(console);
@@ -1497,28 +1590,21 @@ static int vboxDomainShutdown(virDomainPtr dom) {
cleanup:
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
static int vboxDomainReboot(virDomainPtr dom, unsigned int flags ATTRIBUTE_UNUSED) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
IConsole *console = NULL;
PRUint32 state = MachineState_Null;
PRBool isAccessible = PR_FALSE;
nsresult rc;
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN,
_("no domain with matching id %d"), dom->id);
@@ -1533,7 +1619,7 @@ static int vboxDomainReboot(virDomainPtr dom, unsigned int flags ATTRIBUTE_UNUSE
machine->vtbl->GetState(machine, &state);
if (state == MachineState_Running) {
- data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid);
+ data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (console) {
console->vtbl->Reset(console);
@@ -1550,28 +1636,21 @@ static int vboxDomainReboot(virDomainPtr dom, unsigned int flags ATTRIBUTE_UNUSE
cleanup:
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
static int vboxDomainDestroy(virDomainPtr dom) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
IConsole *console = NULL;
PRUint32 state = MachineState_Null;
PRBool isAccessible = PR_FALSE;
nsresult rc;
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN,
_("no domain with matching id %d"), dom->id);
@@ -1591,7 +1670,7 @@ static int vboxDomainDestroy(virDomainPtr dom) {
goto cleanup;
}
- data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid);
+ data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (console) {
@@ -1614,7 +1693,7 @@ static int vboxDomainDestroy(virDomainPtr dom) {
cleanup:
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
@@ -1635,20 +1714,13 @@ static char *vboxDomainGetOSType(virDomainPtr dom ATTRIBUTE_UNUSED) {
static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
PRUint32 state = MachineState_Null;
PRBool isAccessible = PR_FALSE;
nsresult rc;
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN,
_("no domain with matching id %d"), dom->id);
@@ -1668,7 +1740,7 @@ static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) {
goto cleanup;
}
- rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid);
+ rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid.value);
if (NS_SUCCEEDED(rc)) {
rc = data->vboxSession->vtbl->GetMachine(data->vboxSession, &machine);
if (NS_SUCCEEDED(rc) && machine) {
@@ -1690,7 +1762,7 @@ static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) {
cleanup:
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
@@ -1801,7 +1873,7 @@ cleanup:
static int vboxDomainSave(virDomainPtr dom, const char *path ATTRIBUTE_UNUSED) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IConsole *console = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
nsresult rc;
/* VirtualBox currently doesn't support saving to a file
@@ -1810,16 +1882,10 @@ static int vboxDomainSave(virDomainPtr dom, const char *path ATTRIBUTE_UNUSED) {
* this behaviour once get the VirtualBox API in right
* shape to do this
*/
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
/* Open a Session for the machine */
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
if (NS_SUCCEEDED(rc)) {
rc = data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (NS_SUCCEEDED(rc) && console) {
@@ -1846,12 +1912,9 @@ static int vboxDomainSave(virDomainPtr dom, const char *path ATTRIBUTE_UNUSED) {
data->vboxSession->vtbl->Close(data->vboxSession);
}
- DEBUGIID("UUID of machine being saved:", iid);
+ DEBUGIID("UUID of machine being saved:", iid.value);
-#if VBOX_API_VERSION == 2002
-cleanup:
-#endif
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
@@ -1861,7 +1924,7 @@ vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
{
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
PRUint32 CPUCount = nvcpus;
nsresult rc;
@@ -1870,16 +1933,8 @@ vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
return -1;
}
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
-
- rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid.value);
if (NS_SUCCEEDED(rc)) {
data->vboxSession->vtbl->GetMachine(data->vboxSession, &machine);
if (machine) {
@@ -1904,10 +1959,7 @@ vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
}
data->vboxSession->vtbl->Close(data->vboxSession);
-#if VBOX_API_VERSION == 2002
-cleanup:
-#endif
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
@@ -1957,26 +2009,19 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
VBOX_OBJECT_CHECK(dom->conn, char *, NULL);
virDomainDefPtr def = NULL;
IMachine *machine = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
int gotAllABoutDef = -1;
nsresult rc;
char *tmp;
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
if (VIR_ALLOC(def) < 0) {
virReportOOMError();
goto cleanup;
}
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
- if (NS_SUCCEEDED(rc) && machine) {
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
+ if (NS_SUCCEEDED(rc)) {
PRBool accessible = PR_FALSE;
machine->vtbl->GetAccessible(machine, &accessible);
@@ -3077,7 +3122,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
ret = virDomainDefFormat(def, flags);
cleanup:
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
virDomainDefFree(def);
return ret;
}
@@ -3301,7 +3346,7 @@ vboxStartMachine(virDomainPtr dom, int i, IMachine *machine, vboxIID *iid)
rc = data->vboxObj->vtbl->OpenRemoteSession(data->vboxObj,
data->vboxSession,
- iid,
+ iid->value,
sessionType,
env,
&progress );
@@ -3346,7 +3391,7 @@ vboxStartMachine(virDomainPtr dom, int i, IMachine *machine, vboxIID *iid)
static int vboxDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
vboxArray machines = VBOX_ARRAY_INITIALIZER;
- unsigned char iidl[VIR_UUID_BUFLEN] = {0};
+ unsigned char uuid[VIR_UUID_BUFLEN] = {0};
nsresult rc;
int i = 0;
@@ -3374,21 +3419,21 @@ static int vboxDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) {
machine->vtbl->GetAccessible(machine, &isAccessible);
if (isAccessible) {
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
- machine->vtbl->GetId(machine, &iid);
- if (!iid)
+ rc = machine->vtbl->GetId(machine, &iid.value);
+ if (NS_FAILED(rc))
continue;
- vboxIIDToUUID(iidl, iid);
+ vboxIIDToUUID(&iid, uuid);
- if (memcmp(dom->uuid, iidl, VIR_UUID_BUFLEN) == 0) {
+ if (memcmp(dom->uuid, uuid, VIR_UUID_BUFLEN) == 0) {
PRUint32 state = MachineState_Null;
machine->vtbl->GetState(machine, &state);
if ( (state == MachineState_PoweredOff) ||
(state == MachineState_Saved) ||
(state == MachineState_Aborted) ) {
- ret = vboxStartMachine(dom, i, machine, iid);
+ ret = vboxStartMachine(dom, i, machine, &iid);
} else {
vboxError(VIR_ERR_OPERATION_FAILED, "%s",
_("machine is not in poweroff|saved|"
@@ -3396,7 +3441,7 @@ static int vboxDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) {
ret = -1;
}
}
- vboxIIDUnalloc(iid);
+ vboxIIDUnalloc(&iid);
if (ret != -1)
break;
}
@@ -3506,54 +3551,41 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
if (dvdDrive) {
IDVDImage *dvdImage = NULL;
PRUnichar *dvdfileUtf16 = NULL;
- vboxIID *dvduuid = NULL;
-# if VBOX_API_VERSION == 2002
- nsID dvdemptyuuid;
-
- memset(&dvdemptyuuid, 0, sizeof(dvdemptyuuid));
-# else
- PRUnichar *dvdemptyuuidUtf16 = NULL;
-# endif
+ vboxIID dvduuid = VBOX_IID_INITIALIZER;
+ vboxIID dvdemptyuuid = VBOX_IID_INITIALIZER;
VBOX_UTF8_TO_UTF16(def->disks[i]->src, &dvdfileUtf16);
data->vboxObj->vtbl->FindDVDImage(data->vboxObj,
dvdfileUtf16, &dvdImage);
if (!dvdImage) {
-# if VBOX_API_VERSION == 2002
data->vboxObj->vtbl->OpenDVDImage(data->vboxObj,
dvdfileUtf16,
- &dvdemptyuuid,
+ dvdemptyuuid.value,
&dvdImage);
-# else
- data->vboxObj->vtbl->OpenDVDImage(data->vboxObj,
- dvdfileUtf16,
- dvdemptyuuidUtf16,
- &dvdImage);
-# endif
}
if (dvdImage) {
rc = dvdImage->vtbl->imedium.GetId((IMedium *)dvdImage,
- &dvduuid);
+ &dvduuid.value);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("can't get the uuid of the file to "
"be attached to cdrom: %s, rc=%08x"),
def->disks[i]->src, (unsigned)rc);
} else {
- rc = dvdDrive->vtbl->MountImage(dvdDrive, dvduuid);
+ rc = dvdDrive->vtbl->MountImage(dvdDrive, dvduuid.value);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not attach the file to cdrom: %s, rc=%08x"),
def->disks[i]->src, (unsigned)rc);
} else {
- DEBUGIID("CD/DVDImage UUID:", dvduuid);
+ DEBUGIID("CD/DVDImage UUID:", dvduuid.value);
}
}
VBOX_MEDIUM_RELEASE(dvdImage);
}
- vboxIIDUnalloc(dvduuid);
+ vboxIIDUnalloc(&dvduuid);
VBOX_UTF16_FREE(dvdfileUtf16);
VBOX_RELEASE(dvdDrive);
}
@@ -3564,7 +3596,7 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
def->disks[i]->src != NULL) {
IHardDisk *hardDisk = NULL;
PRUnichar *hddfileUtf16 = NULL;
- vboxIID *hdduuid = NULL;
+ vboxIID hdduuid = VBOX_IID_INITIALIZER;
PRUnichar *hddEmpty = NULL;
/* Current Limitation: Harddisk can't be connected to
* Secondary Master as Secondary Master is always used
@@ -3598,7 +3630,7 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
if (hardDisk) {
rc = hardDisk->vtbl->imedium.GetId((IMedium *)hardDisk,
- &hdduuid);
+ &hdduuid.value);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("can't get the uuid of the file to be "
@@ -3639,7 +3671,7 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
}
rc = machine->vtbl->AttachHardDisk(machine,
- hdduuid,
+ hdduuid.value,
hddcnameUtf16,
channel,
device);
@@ -3651,14 +3683,14 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
"harddisk: %s, rc=%08x"),
def->disks[i]->src, (unsigned)rc);
} else {
- DEBUGIID("Attached HDD with UUID", hdduuid);
+ DEBUGIID("Attached HDD with UUID", hdduuid.value);
}
}
}
}
VBOX_MEDIUM_RELEASE(hardDisk);
}
- vboxIIDUnalloc(hdduuid);
+ vboxIIDUnalloc(&hdduuid);
VBOX_UTF16_FREE(hddEmpty);
VBOX_UTF16_FREE(hddfileUtf16);
} else if (def->disks[i]->type == VIR_DOMAIN_DISK_TYPE_BLOCK) {
@@ -3673,14 +3705,8 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
if (NS_SUCCEEDED(rc)) {
IFloppyImage *floppyImage = NULL;
PRUnichar *fdfileUtf16 = NULL;
- vboxIID *fduuid = NULL;
-# if VBOX_API_VERSION == 2002
- nsID fdemptyuuid;
-
- memset(&fdemptyuuid, 0, sizeof(fdemptyuuid));
-# else
- PRUnichar *fdemptyuuidUtf16 = NULL;
-# endif
+ vboxIID fduuid = VBOX_IID_INITIALIZER;
+ vboxIID fdemptyuuid = VBOX_IID_INITIALIZER;
VBOX_UTF8_TO_UTF16(def->disks[i]->src, &fdfileUtf16);
rc = data->vboxObj->vtbl->FindFloppyImage(data->vboxObj,
@@ -3690,17 +3716,13 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
if (!floppyImage) {
data->vboxObj->vtbl->OpenFloppyImage(data->vboxObj,
fdfileUtf16,
-# if VBOX_API_VERSION == 2002
- &fdemptyuuid,
-# else
- fdemptyuuidUtf16,
-# endif
+ fdemptyuuid.value,
&floppyImage);
}
if (floppyImage) {
rc = floppyImage->vtbl->imedium.GetId((IMedium *)floppyImage,
- &fduuid);
+ &fduuid.value);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("can't get the uuid of the file to "
@@ -3708,19 +3730,19 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
def->disks[i]->src, (unsigned)rc);
} else {
rc = floppyDrive->vtbl->MountImage(floppyDrive,
- fduuid);
+ fduuid.value);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not attach the file to "
"floppy drive: %s, rc=%08x"),
def->disks[i]->src, (unsigned)rc);
} else {
- DEBUGIID("floppyImage UUID", fduuid);
+ DEBUGIID("floppyImage UUID", fduuid.value);
}
}
VBOX_MEDIUM_RELEASE(floppyImage);
}
- vboxIIDUnalloc(fduuid);
+ vboxIIDUnalloc(&fduuid);
VBOX_UTF16_FREE(fdfileUtf16);
}
VBOX_RELEASE(floppyDrive);
@@ -4554,8 +4576,8 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
VBOX_OBJECT_CHECK(conn, virDomainPtr, NULL);
IMachine *machine = NULL;
IBIOSSettings *bios = NULL;
- vboxIID *iid = NULL;
- vboxIID *mchiid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
+ vboxIID mchiid = VBOX_IID_INITIALIZER;
virDomainDefPtr def = NULL;
PRUnichar *machineNameUtf16 = NULL;
#if VBOX_API_VERSION >= 3002
@@ -4568,28 +4590,21 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
goto cleanup;
}
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
VBOX_UTF8_TO_UTF16(def->name, &machineNameUtf16);
- vboxIIDFromUUID(def->uuid, iid);
+ vboxIIDFromUUID(&iid, def->uuid);
#if VBOX_API_VERSION < 3002
rc = data->vboxObj->vtbl->CreateMachine(data->vboxObj,
machineNameUtf16,
NULL,
NULL,
- iid,
+ iid.value,
&machine);
#else /* VBOX_API_VERSION >= 3002 */
rc = data->vboxObj->vtbl->CreateMachine(data->vboxObj,
machineNameUtf16,
NULL,
NULL,
- iid,
+ iid.value,
override,
&machine);
#endif /* VBOX_API_VERSION >= 3002 */
@@ -4672,8 +4687,8 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
* object so open a session to it and get it back, so that
* you can make changes to the machine setting
*/
- machine->vtbl->GetId(machine, &mchiid);
- data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, mchiid);
+ machine->vtbl->GetId(machine, &mchiid.value);
+ data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, mchiid.value);
data->vboxSession->vtbl->GetMachine(data->vboxSession, &machine);
vboxSetBootDeviceOrder(def, data, machine);
@@ -4691,20 +4706,20 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
*/
rc = machine->vtbl->SaveSettings(machine);
data->vboxSession->vtbl->Close(data->vboxSession);
- vboxIIDUnalloc(mchiid);
+ vboxIIDUnalloc(&mchiid);
ret = virGetDomain(conn, def->name, def->uuid);
VBOX_RELEASE(machine);
machine = NULL;
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
virDomainDefFree(def);
return ret;
cleanup:
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
virDomainDefFree(def);
return NULL;
}
@@ -4712,17 +4727,10 @@ cleanup:
static int vboxDomainUndefine(virDomainPtr dom) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
nsresult rc;
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
+ vboxIIDFromUUID(&iid, dom->uuid);
/* Block for checking if HDD's are attched to VM.
* considering just IDE bus for now. Also skipped
@@ -4737,7 +4745,7 @@ static int vboxDomainUndefine(virDomainPtr dom) {
VIR_FREE(hddcname);
/* Open a Session for the machine */
- rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid);
+ rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid.value);
if (NS_SUCCEEDED(rc)) {
rc = data->vboxSession->vtbl->GetMachine(data->vboxSession, &machine);
if (NS_SUCCEEDED(rc) && machine) {
@@ -4805,8 +4813,8 @@ static int vboxDomainUndefine(virDomainPtr dom) {
VBOX_UTF16_FREE(hddcnameUtf16);
}
- rc = data->vboxObj->vtbl->UnregisterMachine(data->vboxObj, iid, &machine);
- DEBUGIID("UUID of machine being undefined", iid);
+ rc = data->vboxObj->vtbl->UnregisterMachine(data->vboxObj, iid.value, &machine);
+ DEBUGIID("UUID of machine being undefined", iid.value);
if (NS_SUCCEEDED(rc) && machine){
machine->vtbl->DeleteSettings(machine);
@@ -4816,10 +4824,7 @@ static int vboxDomainUndefine(virDomainPtr dom) {
_("could not delete the domain, rc=%08x"), (unsigned)rc);
}
-#if VBOX_API_VERSION == 2002
-cleanup:
-#endif
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
VBOX_RELEASE(machine);
return ret;
@@ -4830,7 +4835,7 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
int mediaChangeOnly ATTRIBUTE_UNUSED) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
PRUint32 state = MachineState_Null;
virDomainDefPtr def = NULL;
virDomainDeviceDefPtr dev = NULL;
@@ -4855,16 +4860,8 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
goto cleanup;
}
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
-
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching uuid"));
@@ -4876,9 +4873,9 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
if ((state == MachineState_Running) ||
(state == MachineState_Paused)) {
- rc = data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid);
+ rc = data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
} else {
- rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid);
+ rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid.value);
}
if (NS_SUCCEEDED(rc)) {
rc = data->vboxSession->vtbl->GetMachine(data->vboxSession, &machine);
@@ -4897,27 +4894,17 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
if (dvdDrive) {
IDVDImage *dvdImage = NULL;
PRUnichar *dvdfileUtf16 = NULL;
- vboxIID *dvduuid = NULL;
-# if VBOX_API_VERSION == 2002
- nsID dvdemptyuuid;
-
- memset(&dvdemptyuuid, 0, sizeof(dvdemptyuuid));
-# else
- PRUnichar *dvdemptyuuidUtf16 = NULL;
-# endif
+ vboxIID dvduuid = VBOX_IID_INITIALIZER;
+ vboxIID dvdemptyuuid = VBOX_IID_INITIALIZER;
VBOX_UTF8_TO_UTF16(dev->data.disk->src, &dvdfileUtf16);
data->vboxObj->vtbl->FindDVDImage(data->vboxObj, dvdfileUtf16, &dvdImage);
if (!dvdImage) {
-# if VBOX_API_VERSION == 2002
- data->vboxObj->vtbl->OpenDVDImage(data->vboxObj, dvdfileUtf16, &dvdemptyuuid, &dvdImage);
-# else
- data->vboxObj->vtbl->OpenDVDImage(data->vboxObj, dvdfileUtf16, dvdemptyuuidUtf16, &dvdImage);
-# endif
+ data->vboxObj->vtbl->OpenDVDImage(data->vboxObj, dvdfileUtf16, dvdemptyuuid.value, &dvdImage);
}
if (dvdImage) {
- rc = dvdImage->vtbl->imedium.GetId((IMedium *)dvdImage, &dvduuid);
+ rc = dvdImage->vtbl->imedium.GetId((IMedium *)dvdImage, &dvduuid.value);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("can't get the uuid of the file to "
@@ -4926,20 +4913,20 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
} else {
/* unmount the previous mounted image */
dvdDrive->vtbl->Unmount(dvdDrive);
- rc = dvdDrive->vtbl->MountImage(dvdDrive, dvduuid);
+ rc = dvdDrive->vtbl->MountImage(dvdDrive, dvduuid.value);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not attach the file to cdrom: %s, rc=%08x"),
dev->data.disk->src, (unsigned)rc);
} else {
ret = 0;
- DEBUGIID("CD/DVD Image UUID:", dvduuid);
+ DEBUGIID("CD/DVD Image UUID:", dvduuid.value);
}
}
VBOX_MEDIUM_RELEASE(dvdImage);
}
- vboxIIDUnalloc(dvduuid);
+ vboxIIDUnalloc(&dvduuid);
VBOX_UTF16_FREE(dvdfileUtf16);
VBOX_RELEASE(dvdDrive);
}
@@ -4955,14 +4942,8 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
if (NS_SUCCEEDED(rc)) {
IFloppyImage *floppyImage = NULL;
PRUnichar *fdfileUtf16 = NULL;
- vboxIID *fduuid = NULL;
-# if VBOX_API_VERSION == 2002
- nsID fdemptyuuid;
-
- memset(&fdemptyuuid, 0, sizeof(fdemptyuuid));
-# else
- PRUnichar *fdemptyuuidUtf16 = NULL;
-# endif
+ vboxIID fduuid = VBOX_IID_INITIALIZER;
+ vboxIID fdemptyuuid = VBOX_IID_INITIALIZER;
VBOX_UTF8_TO_UTF16(dev->data.disk->src, &fdfileUtf16);
rc = data->vboxObj->vtbl->FindFloppyImage(data->vboxObj,
fdfileUtf16,
@@ -4971,35 +4952,31 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
if (!floppyImage) {
data->vboxObj->vtbl->OpenFloppyImage(data->vboxObj,
fdfileUtf16,
-# if VBOX_API_VERSION == 2002
- &fdemptyuuid,
-# else
- fdemptyuuidUtf16,
-# endif
+ fdemptyuuid.value,
&floppyImage);
}
if (floppyImage) {
- rc = floppyImage->vtbl->imedium.GetId((IMedium *)floppyImage, &fduuid);
+ rc = floppyImage->vtbl->imedium.GetId((IMedium *)floppyImage, &fduuid.value);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("can't get the uuid of the file to be "
"attached to floppy drive: %s, rc=%08x"),
dev->data.disk->src, (unsigned)rc);
} else {
- rc = floppyDrive->vtbl->MountImage(floppyDrive, fduuid);
+ rc = floppyDrive->vtbl->MountImage(floppyDrive, fduuid.value);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not attach the file to floppy drive: %s, rc=%08x"),
dev->data.disk->src, (unsigned)rc);
} else {
ret = 0;
- DEBUGIID("attached floppy, UUID:", fduuid);
+ DEBUGIID("attached floppy, UUID:", fduuid.value);
}
}
VBOX_MEDIUM_RELEASE(floppyImage);
}
- vboxIIDUnalloc(fduuid);
+ vboxIIDUnalloc(&fduuid);
VBOX_UTF16_FREE(fdfileUtf16);
}
VBOX_RELEASE(floppyDrive);
@@ -5024,7 +5001,7 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
}
cleanup:
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
virDomainDefFree(def);
virDomainDeviceDefFree(dev);
return ret;
@@ -5063,7 +5040,7 @@ static int vboxDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml,
static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
PRUint32 state = MachineState_Null;
virDomainDefPtr def = NULL;
virDomainDeviceDefPtr dev = NULL;
@@ -5088,16 +5065,8 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) {
goto cleanup;
}
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
-
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching uuid"));
@@ -5109,9 +5078,9 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) {
if ((state == MachineState_Running) ||
(state == MachineState_Paused)) {
- rc = data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid);
+ rc = data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
} else {
- rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid);
+ rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid.value);
}
if (NS_SUCCEEDED(rc)) {
@@ -5186,7 +5155,7 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) {
}
cleanup:
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
virDomainDefFree(def);
virDomainDeviceDefFree(dev);
return ret;
@@ -5208,6 +5177,7 @@ vboxDomainSnapshotGetAll(virDomainPtr dom,
IMachine *machine,
ISnapshot ***snapshots)
{
+ vboxIID empty = VBOX_IID_INITIALIZER;
ISnapshot **list = NULL;
PRUint32 count;
nsresult rc;
@@ -5230,7 +5200,7 @@ vboxDomainSnapshotGetAll(virDomainPtr dom,
goto error;
}
- rc = machine->vtbl->GetSnapshot(machine, NULL, list);
+ rc = machine->vtbl->GetSnapshot(machine, empty.value, list);
if (NS_FAILED(rc) || !list[0]) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not get root snapshot for domain %s"),
@@ -5347,7 +5317,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
{
VBOX_OBJECT_CHECK(dom->conn, virDomainSnapshotPtr, NULL);
virDomainSnapshotDefPtr def = NULL;
- vboxIID *domiid = NULL;
+ vboxIID domiid = VBOX_IID_INITIALIZER;
IMachine *machine = NULL;
IConsole *console = NULL;
IProgress *progress = NULL;
@@ -5367,16 +5337,9 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
if (!(def = virDomainSnapshotDefParseString(xmlDesc, 1)))
goto cleanup;
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(domiid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, domiid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid, &machine);
- if (NS_FAILED(rc) || !machine) {
+ vboxIIDFromUUID(&domiid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid.value, &machine);
+ if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
@@ -5393,11 +5356,11 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
&& (state <= MachineState_LastOnline)) {
rc = data->vboxObj->vtbl->OpenExistingSession(data->vboxObj,
data->vboxSession,
- domiid);
+ domiid.value);
} else {
rc = data->vboxObj->vtbl->OpenSession(data->vboxObj,
data->vboxSession,
- domiid);
+ domiid.value);
}
if (NS_SUCCEEDED(rc))
rc = data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
@@ -5454,7 +5417,7 @@ cleanup:
VBOX_RELEASE(console);
data->vboxSession->vtbl->Close(data->vboxSession);
VBOX_RELEASE(machine);
- vboxIIDFree(domiid);
+ vboxIIDUnalloc(&domiid);
virDomainSnapshotDefFree(def);
return ret;
}
@@ -5465,7 +5428,7 @@ vboxDomainSnapshotDumpXML(virDomainSnapshotPtr snapshot,
{
virDomainPtr dom = snapshot->domain;
VBOX_OBJECT_CHECK(dom->conn, char *, NULL);
- vboxIID *domiid = NULL;
+ vboxIID domiid = VBOX_IID_INITIALIZER;
IMachine *machine = NULL;
ISnapshot *snap = NULL;
ISnapshot *parent = NULL;
@@ -5479,15 +5442,8 @@ vboxDomainSnapshotDumpXML(virDomainSnapshotPtr snapshot,
virCheckFlags(0, NULL);
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(domiid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, domiid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid, &machine);
+ vboxIIDFromUUID(&domiid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
@@ -5570,7 +5526,7 @@ cleanup:
VBOX_RELEASE(parent);
VBOX_RELEASE(snap);
VBOX_RELEASE(machine);
- vboxIIDFree(domiid);
+ vboxIIDUnalloc(&domiid);
return ret;
no_memory:
@@ -5583,22 +5539,15 @@ vboxDomainSnapshotNum(virDomainPtr dom,
unsigned int flags)
{
VBOX_OBJECT_CHECK(dom->conn, int, -1);
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
IMachine *machine = NULL;
nsresult rc;
PRUint32 snapshotCount;
virCheckFlags(0, -1);
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
@@ -5617,7 +5566,7 @@ vboxDomainSnapshotNum(virDomainPtr dom,
cleanup:
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
@@ -5628,7 +5577,7 @@ vboxDomainSnapshotListNames(virDomainPtr dom,
unsigned int flags)
{
VBOX_OBJECT_CHECK(dom->conn, int, -1);
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
IMachine *machine = NULL;
nsresult rc;
ISnapshot **snapshots = NULL;
@@ -5637,15 +5586,8 @@ vboxDomainSnapshotListNames(virDomainPtr dom,
virCheckFlags(0, -1);
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
@@ -5690,7 +5632,7 @@ cleanup:
}
VIR_FREE(snapshots);
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
@@ -5700,22 +5642,15 @@ vboxDomainSnapshotLookupByName(virDomainPtr dom,
unsigned int flags)
{
VBOX_OBJECT_CHECK(dom->conn, virDomainSnapshotPtr, NULL);
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
IMachine *machine = NULL;
ISnapshot *snapshot = NULL;
nsresult rc;
virCheckFlags(0, NULL);
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
@@ -5730,7 +5665,7 @@ vboxDomainSnapshotLookupByName(virDomainPtr dom,
cleanup:
VBOX_RELEASE(snapshot);
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
@@ -5739,23 +5674,16 @@ vboxDomainHasCurrentSnapshot(virDomainPtr dom,
unsigned int flags)
{
VBOX_OBJECT_CHECK(dom->conn, int, -1);
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
IMachine *machine = NULL;
ISnapshot *snapshot = NULL;
nsresult rc;
virCheckFlags(0, -1);
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
- if (NS_FAILED(rc) || !machine) {
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
+ if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
@@ -5775,7 +5703,7 @@ vboxDomainHasCurrentSnapshot(virDomainPtr dom,
cleanup:
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
@@ -5784,7 +5712,7 @@ vboxDomainSnapshotCurrent(virDomainPtr dom,
unsigned int flags)
{
VBOX_OBJECT_CHECK(dom->conn, virDomainSnapshotPtr, NULL);
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
IMachine *machine = NULL;
ISnapshot *snapshot = NULL;
PRUnichar *nameUtf16 = NULL;
@@ -5793,16 +5721,9 @@ vboxDomainSnapshotCurrent(virDomainPtr dom,
virCheckFlags(0, NULL);
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
- if (NS_FAILED(rc) || !machine) {
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
+ if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
@@ -5841,7 +5762,7 @@ cleanup:
VBOX_UTF16_FREE(nameUtf16);
VBOX_RELEASE(snapshot);
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
@@ -5852,17 +5773,17 @@ vboxDomainSnapshotRestore(virDomainPtr dom,
ISnapshot *snapshot)
{
VBOX_OBJECT_CHECK(dom->conn, int, -1);
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
nsresult rc;
- rc = snapshot->vtbl->GetId(snapshot, &iid);
- if (NS_FAILED(rc) || !iid) {
+ rc = snapshot->vtbl->GetId(snapshot, &iid.value);
+ if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not get snapshot UUID"));
goto cleanup;
}
- rc = machine->vtbl->SetCurrentSnapshot(machine, iid);
+ rc = machine->vtbl->SetCurrentSnapshot(machine, iid.value);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not restore snapshot for domain %s"), dom->name);
@@ -5872,7 +5793,7 @@ vboxDomainSnapshotRestore(virDomainPtr dom,
ret = 0;
cleanup:
- vboxIIDUnalloc(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
#else
@@ -5887,10 +5808,10 @@ vboxDomainSnapshotRestore(virDomainPtr dom,
PRUint32 state;
nsresult rc;
PRInt32 result;
- vboxIID *domiid;
+ vboxIID domiid = VBOX_IID_INITIALIZER;
- rc = machine->vtbl->GetId(machine, &domiid);
- if (NS_FAILED(rc) || !domiid) {
+ rc = machine->vtbl->GetId(machine, &domiid.value);
+ if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not get domain UUID"));
goto cleanup;
@@ -5911,7 +5832,7 @@ vboxDomainSnapshotRestore(virDomainPtr dom,
}
rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession,
- domiid);
+ domiid.value);
if (NS_SUCCEEDED(rc))
rc = data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (NS_FAILED(rc)) {
@@ -5948,6 +5869,7 @@ cleanup:
VBOX_RELEASE(progress);
VBOX_RELEASE(console);
data->vboxSession->vtbl->Close(data->vboxSession);
+ vboxIIDUnalloc(&domiid);
return ret;
}
#endif
@@ -5958,7 +5880,7 @@ vboxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
{
virDomainPtr dom = snapshot->domain;
VBOX_OBJECT_CHECK(dom->conn, int, -1);
- vboxIID *domiid = NULL;
+ vboxIID domiid = VBOX_IID_INITIALIZER;
IMachine *machine = NULL;
ISnapshot *newSnapshot = NULL;
ISnapshot *prevSnapshot = NULL;
@@ -5968,15 +5890,8 @@ vboxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
virCheckFlags(0, -1);
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(domiid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, domiid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid, &machine);
+ vboxIIDFromUUID(&domiid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
@@ -6030,7 +5945,7 @@ vboxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
cleanup:
VBOX_RELEASE(prevSnapshot);
VBOX_RELEASE(newSnapshot);
- vboxIIDUnalloc(domiid);
+ vboxIIDUnalloc(&domiid);
return ret;
}
@@ -6040,7 +5955,7 @@ vboxDomainSnapshotDeleteSingle(vboxGlobalData *data,
ISnapshot *snapshot)
{
IProgress *progress = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
int ret = -1;
nsresult rc;
#if VBOX_API_VERSION == 2002
@@ -6049,17 +5964,17 @@ vboxDomainSnapshotDeleteSingle(vboxGlobalData *data,
PRInt32 result;
#endif
- rc = snapshot->vtbl->GetId(snapshot, &iid);
- if (NS_FAILED(rc) || !iid) {
+ rc = snapshot->vtbl->GetId(snapshot, &iid.value);
+ if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not get snapshot UUID"));
goto cleanup;
}
#if VBOX_API_VERSION < 3001
- rc = console->vtbl->DiscardSnapshot(console, iid, &progress);
+ rc = console->vtbl->DiscardSnapshot(console, iid.value, &progress);
#else
- rc = console->vtbl->DeleteSnapshot(console, iid, &progress);
+ rc = console->vtbl->DeleteSnapshot(console, iid.value, &progress);
#endif
if (NS_FAILED(rc) || !progress) {
if (rc == VBOX_E_INVALID_VM_STATE) {
@@ -6084,7 +5999,7 @@ vboxDomainSnapshotDeleteSingle(vboxGlobalData *data,
cleanup:
VBOX_RELEASE(progress);
- vboxIIDUnalloc(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
@@ -6123,7 +6038,7 @@ vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
{
virDomainPtr dom = snapshot->domain;
VBOX_OBJECT_CHECK(dom->conn, int, -1);
- vboxIID *domiid = NULL;
+ vboxIID domiid = VBOX_IID_INITIALIZER;
IMachine *machine = NULL;
ISnapshot *snap = NULL;
IConsole *console = NULL;
@@ -6132,16 +6047,8 @@ vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN, -1);
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(domiid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, domiid);
-
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid, &machine);
+ vboxIIDFromUUID(&domiid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
@@ -6167,7 +6074,7 @@ vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
}
rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession,
- domiid);
+ domiid.value);
if (NS_SUCCEEDED(rc))
rc = data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (NS_FAILED(rc)) {
@@ -6185,7 +6092,7 @@ vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
cleanup:
VBOX_RELEASE(console);
VBOX_RELEASE(snap);
- vboxIIDUnalloc(domiid);
+ vboxIIDUnalloc(&domiid);
data->vboxSession->vtbl->Close(data->vboxSession);
return ret;
}
@@ -6943,25 +6850,20 @@ static int vboxListDefinedNetworks(virConnectPtr conn, char **const names, int n
return ret;
}
-static virNetworkPtr vboxNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid) {
+static virNetworkPtr
+vboxNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
+{
VBOX_OBJECT_HOST_CHECK(conn, virNetworkPtr, NULL);
- vboxIID *iid = NULL;
-
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
+ vboxIID iid = VBOX_IID_INITIALIZER;
- vboxIIDFromUUID(uuid, iid);
+ vboxIIDFromUUID(&iid, uuid);
/* TODO: "internal" networks are just strings and
* thus can't do much with them
*/
IHostNetworkInterface *networkInterface = NULL;
- host->vtbl->FindHostNetworkInterfaceById(host, iid, &networkInterface);
+ host->vtbl->FindHostNetworkInterfaceById(host, iid.value, &networkInterface);
if (networkInterface) {
PRUint32 interfaceType = 0;
@@ -6977,7 +6879,7 @@ static virNetworkPtr vboxNetworkLookupByUUID(virConnectPtr conn, const unsigned
ret = virGetNetwork(conn, nameUtf8, uuid);
DEBUG("Network Name: %s", nameUtf8);
- DEBUGIID("Network UUID", iid);
+ DEBUGIID("Network UUID", iid.value);
VBOX_UTF8_FREE(nameUtf8);
VBOX_UTF16_FREE(nameUtf16);
@@ -6988,10 +6890,7 @@ static virNetworkPtr vboxNetworkLookupByUUID(virConnectPtr conn, const unsigned
VBOX_RELEASE(host);
-#if VBOX_API_VERSION == 2002
-cleanup:
-#endif
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
@@ -7011,15 +6910,15 @@ static virNetworkPtr vboxNetworkLookupByName(virConnectPtr conn, const char *nam
if (interfaceType == HostNetworkInterfaceType_HostOnly) {
unsigned char uuid[VIR_UUID_BUFLEN];
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
- networkInterface->vtbl->GetId(networkInterface, &iid);
- vboxIIDToUUID(uuid, iid);
+ networkInterface->vtbl->GetId(networkInterface, &iid.value);
+ vboxIIDToUUID(&iid, uuid);
ret = virGetNetwork(conn, name, uuid);
DEBUG("Network Name: %s", name);
- DEBUGIID("Network UUID", iid);
- vboxIIDUnalloc(iid);
+ DEBUGIID("Network UUID", iid.value);
+ vboxIIDUnalloc(&iid);
}
VBOX_RELEASE(networkInterface);
@@ -7036,6 +6935,7 @@ static virNetworkPtr vboxNetworkDefineCreateXML(virConnectPtr conn, const char *
PRUnichar *networkInterfaceNameUtf16 = NULL;
char *networkInterfaceNameUtf8 = NULL;
IHostNetworkInterface *networkInterface = NULL;
+ nsresult rc;
virNetworkDefPtr def = virNetworkDefParseString(xml);
@@ -7051,7 +6951,7 @@ static virNetworkPtr vboxNetworkDefineCreateXML(virConnectPtr conn, const char *
*/
#if VBOX_API_VERSION == 2002
- if STREQ(def->name, "vboxnet0") {
+ if (STREQ(def->name, "vboxnet0")) {
PRUint32 interfaceType = 0;
VBOX_UTF8_TO_UTF16(def->name, &networkInterfaceNameUtf16);
@@ -7077,7 +6977,7 @@ static virNetworkPtr vboxNetworkDefineCreateXML(virConnectPtr conn, const char *
unsigned char uuid[VIR_UUID_BUFLEN];
char *networkNameUtf8 = NULL;
PRUnichar *networkNameUtf16 = NULL;
- vboxIID *vboxnetiid = NULL;
+ vboxIID vboxnetiid = VBOX_IID_INITIALIZER;
networkInterface->vtbl->GetName(networkInterface, &networkInterfaceNameUtf16);
if (networkInterfaceNameUtf16) {
@@ -7187,11 +7087,11 @@ static virNetworkPtr vboxNetworkDefineCreateXML(virConnectPtr conn, const char *
networkInterface->vtbl->DhcpRediscover(networkInterface);
}
- networkInterface->vtbl->GetId(networkInterface, &vboxnetiid);
- if (vboxnetiid) {
- vboxIIDToUUID(uuid, vboxnetiid);
- DEBUGIID("Real Network UUID", vboxnetiid);
- vboxIIDUnalloc(vboxnetiid);
+ rc = networkInterface->vtbl->GetId(networkInterface, &vboxnetiid.value);
+ if (NS_SUCCEEDED(rc)) {
+ vboxIIDToUUID(&vboxnetiid, uuid);
+ DEBUGIID("Real Network UUID", vboxnetiid.value);
+ vboxIIDUnalloc(&vboxnetiid);
ret = virGetNetwork(conn, networkInterfaceNameUtf8, uuid);
}
@@ -7414,10 +7314,10 @@ static char *vboxNetworkDumpXML(virNetworkPtr network, int flags ATTRIBUTE_UNUSE
if (def->name != NULL) {
PRUnichar *networkNameUtf16 = NULL;
IDHCPServer *dhcpServer = NULL;
- vboxIID *vboxnet0IID = NULL;
+ vboxIID vboxnet0IID = VBOX_IID_INITIALIZER;
- networkInterface->vtbl->GetId(networkInterface, &vboxnet0IID);
- vboxIIDToUUID(def->uuid, vboxnet0IID);
+ networkInterface->vtbl->GetId(networkInterface, &vboxnet0IID.value);
+ vboxIIDToUUID(&vboxnet0IID, def->uuid);
VBOX_UTF8_TO_UTF16(networkNameUtf8 , &networkNameUtf16);
@@ -7523,8 +7423,8 @@ static char *vboxNetworkDumpXML(virNetworkPtr network, int flags ATTRIBUTE_UNUSE
}
}
- DEBUGIID("Network UUID", vboxnet0IID);
- vboxIIDUnalloc(vboxnet0IID);
+ DEBUGIID("Network UUID", vboxnet0IID.value);
+ vboxIIDUnalloc(&vboxnet0IID);
VBOX_UTF16_FREE(networkNameUtf16);
} else {
virReportOOMError();
@@ -7733,28 +7633,24 @@ static virStorageVolPtr vboxStorageVolLookupByName(virStoragePoolPtr pool, const
}
if (nameUtf8 && STREQ(nameUtf8, name)) {
- vboxIID *hddIID = NULL;
- char *hddIIDUtf8 = NULL;
+ vboxIID hddIID = VBOX_IID_INITIALIZER;
+ unsigned char uuid[VIR_UUID_BUFLEN];
+ char key[VIR_UUID_STRING_BUFLEN] = "";
- VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetId, &hddIID);
+ rc = VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetId, &hddIID.value);
+ if (NS_SUCCEEDED(rc)) {
+ vboxIIDToUUID(&hddIID, uuid);
+ virUUIDFormat(uuid, key);
- if (hddIID) {
- vboxIIDtoUtf8(hddIID, &hddIIDUtf8);
- vboxIIDUnalloc(hddIID);
- }
-
- if (hddIIDUtf8) {
-
- ret = virGetStorageVol(pool->conn, pool->name, name, hddIIDUtf8);
+ ret = virGetStorageVol(pool->conn, pool->name, name, key);
DEBUG("virStorageVolPtr: %p", ret);
DEBUG("Storage Volume Name: %s", name);
- DEBUG("Storage Volume key : %s", hddIIDUtf8);
+ DEBUG("Storage Volume key : %s", key);
DEBUG("Storage Volume Pool: %s", pool->name);
-
- vboxIIDUtf8Free(hddIIDUtf8);
}
+ vboxIIDUnalloc(&hddIID);
VBOX_UTF8_FREE(nameUtf8);
break;
}
@@ -7773,34 +7669,22 @@ static virStorageVolPtr vboxStorageVolLookupByName(virStoragePoolPtr pool, const
static virStorageVolPtr vboxStorageVolLookupByKey(virConnectPtr conn, const char *key) {
VBOX_OBJECT_CHECK(conn, virStorageVolPtr, NULL);
- vboxIID *hddIID = NULL;
+ vboxIID hddIID = VBOX_IID_INITIALIZER;
+ unsigned char uuid[VIR_UUID_BUFLEN];
IHardDisk *hardDisk = NULL;
nsresult rc;
if (!key)
return ret;
-#if VBOX_API_VERSION == 2002
-
- if (VIR_ALLOC(hddIID) < 0) {
- virReportOOMError();
- goto cleanup;
+ if (virUUIDParse(key, uuid) < 0) {
+ vboxError(VIR_ERR_INVALID_ARG,
+ _("Could not parse UUID from '%s'"), key);
+ return NULL;
}
- unsigned char hddUUID[VIR_UUID_BUFLEN];
-
- virUUIDParse(key, hddUUID);
- vboxIIDFromUUID(hddUUID, hddIID);
-
-#else /* VBOX_API_VERSION != 2002 */
-
- VBOX_UTF8_TO_UTF16(key, &hddIID);
- if (!hddIID)
- return ret;
-
-#endif /* VBOX_API_VERSION != 2002 */
-
- rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID, &hardDisk);
+ vboxIIDFromUUID(&hddIID, uuid);
+ rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID.value, &hardDisk);
if (NS_SUCCEEDED(rc)) {
PRUint32 hddstate;
@@ -7833,10 +7717,7 @@ static virStorageVolPtr vboxStorageVolLookupByKey(virConnectPtr conn, const char
VBOX_MEDIUM_RELEASE(hardDisk);
}
-#if VBOX_API_VERSION == 2002
-cleanup:
-#endif /* VBOX_API_VERSION == 2002 */
- vboxIIDFree(hddIID);
+ vboxIIDUnalloc(&hddIID);
return ret;
}
@@ -7862,41 +7743,40 @@ static virStorageVolPtr vboxStorageVolLookupByPath(virConnectPtr conn, const cha
if (hddstate != MediaState_Inaccessible) {
PRUnichar *hddNameUtf16 = NULL;
char *hddNameUtf8 = NULL;
- vboxIID *hddIID = NULL;
- char *hddIIDUtf8 = NULL;
VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetName, &hddNameUtf16);
- VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetId, &hddIID);
if (hddNameUtf16) {
VBOX_UTF16_TO_UTF8(hddNameUtf16, &hddNameUtf8);
VBOX_UTF16_FREE(hddNameUtf16);
}
- if (hddIID) {
- vboxIIDtoUtf8(hddIID, &hddIIDUtf8);
- vboxIIDUnalloc(hddIID);
- }
+ if (hddNameUtf8) {
+ vboxIID hddIID = VBOX_IID_INITIALIZER;
+ unsigned char uuid[VIR_UUID_BUFLEN];
+ char key[VIR_UUID_STRING_BUFLEN] = "";
- if (hddIIDUtf8 && hddNameUtf8) {
+ rc = VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetId, &hddIID.value);
+ if (NS_SUCCEEDED(rc)) {
+ vboxIIDToUUID(&hddIID, uuid);
+ virUUIDFormat(uuid, key);
- /* TODO: currently only one default pool and thus
- * the check below, change it when pools are supported
- */
- if (vboxStorageNumOfPools(conn) == 1)
- ret = virGetStorageVol(conn, "default-pool", hddNameUtf8, hddIIDUtf8);
+ /* TODO: currently only one default pool and thus
+ * the check below, change it when pools are supported
+ */
+ if (vboxStorageNumOfPools(conn) == 1)
+ ret = virGetStorageVol(conn, "default-pool", hddNameUtf8, key);
- DEBUG("Storage Volume Pool: %s", "default-pool");
- DEBUG("Storage Volume Name: %s", hddNameUtf8);
- DEBUG("Storage Volume key : %s", hddIIDUtf8);
+ DEBUG("Storage Volume Pool: %s", "default-pool");
+ DEBUG("Storage Volume Name: %s", hddNameUtf8);
+ DEBUG("Storage Volume key : %s", key);
+ }
+ vboxIIDUnalloc(&hddIID);
}
if (hddNameUtf8)
VBOX_UTF8_FREE(hddNameUtf8);
-
- if (hddIIDUtf8)
- vboxIIDUtf8Free(hddIIDUtf8);
}
VBOX_MEDIUM_RELEASE(hardDisk);
@@ -7963,7 +7843,6 @@ static virStorageVolPtr vboxStorageVolCreateXML(virStoragePoolPtr pool,
rc = hardDisk->vtbl->CreateBaseStorage(hardDisk, logicalSize, variant, &progress);
if (NS_SUCCEEDED(rc) && progress) {
- vboxIID *hddIID = NULL;
#if VBOX_API_VERSION == 2002
nsresult resultCode;
#else
@@ -7974,24 +7853,23 @@ static virStorageVolPtr vboxStorageVolCreateXML(virStoragePoolPtr pool,
progress->vtbl->GetResultCode(progress, &resultCode);
if (NS_SUCCEEDED(resultCode)) {
+ vboxIID hddIID = VBOX_IID_INITIALIZER;
+ unsigned char uuid[VIR_UUID_BUFLEN];
+ char key[VIR_UUID_STRING_BUFLEN] = "";
- rc = VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetId, &hddIID);
+ rc = VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetId, &hddIID.value);
if (NS_SUCCEEDED(rc)) {
- char *hddKey = NULL;
-
- vboxIIDtoUtf8(hddIID, &hddKey);
-
- if (hddKey)
- ret = virGetStorageVol(pool->conn, pool->name, def->name, hddKey);
+ vboxIIDToUUID(&hddIID, uuid);
+ virUUIDFormat(uuid, key);
- vboxIIDUtf8Free(hddKey);
- vboxIIDUnalloc(hddIID);
+ ret = virGetStorageVol(pool->conn, pool->name, def->name, key);
}
+
+ vboxIIDUnalloc(&hddIID);
}
VBOX_RELEASE(progress);
}
-
}
}
@@ -8006,18 +7884,22 @@ cleanup:
static int vboxStorageVolDelete(virStorageVolPtr vol,
unsigned int flags ATTRIBUTE_UNUSED) {
VBOX_OBJECT_CHECK(vol->conn, int, -1);
- vboxIID *hddIID = NULL;
+ vboxIID hddIID = VBOX_IID_INITIALIZER;
+ unsigned char uuid[VIR_UUID_BUFLEN];
IHardDisk *hardDisk = NULL;
int deregister = 0;
nsresult rc;
int i = 0;
int j = 0;
- vboxUtf8toIID(vol->key, &hddIID);
- if (!hddIID)
- return ret;
+ if (virUUIDParse(vol->key, uuid) < 0) {
+ vboxError(VIR_ERR_INVALID_ARG,
+ _("Could not parse UUID from '%s'"), vol->key);
+ return -1;
+ }
- rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID, &hardDisk);
+ vboxIIDFromUUID(&hddIID, uuid);
+ rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID.value, &hardDisk);
if (NS_SUCCEEDED(rc)) {
PRUint32 hddstate;
@@ -8032,13 +7914,27 @@ static int vboxStorageVolDelete(virStorageVolPtr vol,
vboxArrayGet(&machineIds, hardDisk, hardDisk->vtbl->GetMachineIds);
#endif /* VBOX_API_VERSION >= 3001 */
+#if VBOX_API_VERSION == 2002 && defined WIN32
+ /* VirtualBox 2.2 on Windows represents IIDs as GUIDs and the
+ * machineIds array contains direct instances of the GUID struct
+ * instead of pointers to the actual struct instances. But there
+ * is no 128bit width simple item type for a SafeArray to fit a
+ * GUID in. The largest simple type it 64bit width and VirtualBox
+ * uses two of this 64bit items to represents one GUID. Therefore,
+ * we devide the size of the SafeArray by two, to compensate for
+ * this workaround in VirtualBox */
+ machineIds.count /= 2;
+#endif /* VBOX_API_VERSION >= 2002 */
+
machineIdsSize = machineIds.count;
for (i = 0; i < machineIds.count; i++) {
IMachine *machine = NULL;
- vboxIID *machineId = machineIds.items[i];
+ vboxIID machineId = VBOX_IID_INITIALIZER;
+
+ vboxIIDFromArrayItem(&machineId, &machineIds, i);
- rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, machineId);
+ rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, machineId.value);
if (NS_SUCCEEDED(rc)) {
rc = data->vboxSession->vtbl->GetMachine(data->vboxSession, &machine);
@@ -8064,20 +7960,20 @@ static int vboxStorageVolDelete(virStorageVolPtr vol,
rc = hddAttachment->vtbl->GetMedium(hddAttachment, &hdd);
#endif /* VBOX_API_VERSION >= 3001 */
if (NS_SUCCEEDED(rc) && hdd) {
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
- VBOX_MEDIUM_FUNC_ARG1(hdd, GetId, &iid);
- if (iid) {
+ rc = VBOX_MEDIUM_FUNC_ARG1(hdd, GetId, &iid.value);
+ if (NS_SUCCEEDED(rc)) {
- DEBUGIID("HardDisk (to delete) UUID", hddIID);
- DEBUGIID("HardDisk (currently processing) UUID", iid);
+ DEBUGIID("HardDisk (to delete) UUID", hddIID.value);
+ DEBUGIID("HardDisk (currently processing) UUID", iid.value);
- if (vboxIIDEqual(hddIID, iid)) {
+ if (vboxIIDIsEqual(&hddIID, &iid)) {
PRUnichar *controller = NULL;
PRInt32 port = 0;
PRInt32 device = 0;
- DEBUGIID("Found HardDisk to delete, UUID", hddIID);
+ DEBUGIID("Found HardDisk to delete, UUID", hddIID.value);
hddAttachment->vtbl->GetController(hddAttachment, &controller);
hddAttachment->vtbl->GetPort(hddAttachment, &port);
@@ -8101,7 +7997,7 @@ static int vboxStorageVolDelete(virStorageVolPtr vol,
if (controller)
VBOX_UTF16_FREE(controller);
}
- vboxIIDUnalloc(iid);
+ vboxIIDUnalloc(&iid);
}
VBOX_MEDIUM_RELEASE(hdd);
}
@@ -8112,6 +8008,8 @@ static int vboxStorageVolDelete(virStorageVolPtr vol,
}
data->vboxSession->vtbl->Close(data->vboxSession);
}
+
+ vboxIIDUnalloc(&machineId);
}
vboxArrayUnalloc(&machineIds);
@@ -8124,17 +8022,16 @@ static int vboxStorageVolDelete(virStorageVolPtr vol,
if (NS_SUCCEEDED(rc) && progress) {
progress->vtbl->WaitForCompletion(progress, -1);
VBOX_RELEASE(progress);
- DEBUGIID("HardDisk deleted, UUID", hddIID);
+ DEBUGIID("HardDisk deleted, UUID", hddIID.value);
ret = 0;
}
}
-
}
VBOX_MEDIUM_RELEASE(hardDisk);
}
- vboxIIDUtf16Free(hddIID);
+ vboxIIDUnalloc(&hddIID);
return ret;
}
@@ -8142,17 +8039,21 @@ static int vboxStorageVolDelete(virStorageVolPtr vol,
static int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info) {
VBOX_OBJECT_CHECK(vol->conn, int, -1);
IHardDisk *hardDisk = NULL;
- vboxIID *hddIID = NULL;
+ unsigned char uuid[VIR_UUID_BUFLEN];
+ vboxIID hddIID = VBOX_IID_INITIALIZER;
nsresult rc;
if (!info)
return ret;
- vboxUtf8toIID(vol->key, &hddIID);
- if (!hddIID)
+ if (virUUIDParse(vol->key, uuid) < 0) {
+ vboxError(VIR_ERR_INVALID_ARG,
+ _("Could not parse UUID from '%s'"), vol->key);
return ret;
+ }
- rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID, &hardDisk);
+ vboxIIDFromUUID(&hddIID, uuid);
+ rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID.value, &hardDisk);
if (NS_SUCCEEDED(rc)) {
PRUint32 hddstate;
@@ -8180,7 +8081,7 @@ static int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info
VBOX_MEDIUM_RELEASE(hardDisk);
}
- vboxIIDUtf16Free(hddIID);
+ vboxIIDUnalloc(&hddIID);
return ret;
}
@@ -8188,7 +8089,8 @@ static int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info
static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags ATTRIBUTE_UNUSED) {
VBOX_OBJECT_CHECK(vol->conn, char *, NULL);
IHardDisk *hardDisk = NULL;
- vboxIID *hddIID = NULL;
+ unsigned char uuid[VIR_UUID_BUFLEN];
+ vboxIID hddIID = VBOX_IID_INITIALIZER;
virStoragePoolDef pool;
virStorageVolDef def;
int defOk = 0;
@@ -8197,11 +8099,14 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags A
memset(&pool, 0, sizeof(pool));
memset(&def, 0, sizeof(def));
- vboxUtf8toIID(vol->key, &hddIID);
- if (!hddIID)
+ if (virUUIDParse(vol->key, uuid) < 0) {
+ vboxError(VIR_ERR_INVALID_ARG,
+ _("Could not parse UUID from '%s'"), vol->key);
return ret;
+ }
- rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID, &hardDisk);
+ vboxIIDFromUUID(&hddIID, uuid);
+ rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID.value, &hardDisk);
if (NS_SUCCEEDED(rc)) {
PRUint32 hddstate;
@@ -8272,7 +8177,7 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags A
VBOX_MEDIUM_RELEASE(hardDisk);
}
- vboxIIDUtf16Free(hddIID);
+ vboxIIDUnalloc(&hddIID);
if (defOk)
ret = virStorageVolDefFormat(&pool, &def);
@@ -8283,14 +8188,18 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags A
static char *vboxStorageVolGetPath(virStorageVolPtr vol) {
VBOX_OBJECT_CHECK(vol->conn, char *, NULL);
IHardDisk *hardDisk = NULL;
- vboxIID *hddIID = NULL;
+ unsigned char uuid[VIR_UUID_BUFLEN];
+ vboxIID hddIID = VBOX_IID_INITIALIZER;
nsresult rc;
- vboxUtf8toIID(vol->key, &hddIID);
- if (!hddIID)
+ if (virUUIDParse(vol->key, uuid) < 0) {
+ vboxError(VIR_ERR_INVALID_ARG,
+ _("Could not parse UUID from '%s'"), vol->key);
return ret;
+ }
- rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID, &hardDisk);
+ vboxIIDFromUUID(&hddIID, uuid);
+ rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID.value, &hardDisk);
if (NS_SUCCEEDED(rc)) {
PRUint32 hddstate;
@@ -8321,7 +8230,7 @@ static char *vboxStorageVolGetPath(virStorageVolPtr vol) {
VBOX_MEDIUM_RELEASE(hardDisk);
}
- vboxIIDUtf16Free(hddIID);
+ vboxIIDUnalloc(&hddIID);
return ret;
}
--
1.7.0.4
2
2
VIR_ERR_INVALID_DOMAIN is meant for invalid domain pointers.
VIR_ERR_NO_DOMAIN is meant for non-existing domains.
---
src/opennebula/one_driver.c | 16 ++++++++--------
src/openvz/openvz_driver.c | 22 +++++++++++-----------
src/uml/uml_driver.c | 26 +++++++++++++-------------
src/vbox/vbox_tmpl.c | 38 +++++++++++++++++++-------------------
4 files changed, 51 insertions(+), 51 deletions(-)
diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c
index a2d9ab3..b88f44f 100644
--- a/src/opennebula/one_driver.c
+++ b/src/opennebula/one_driver.c
@@ -285,7 +285,7 @@ static int oneDomainUndefine(virDomainPtr dom)
oneDriverLock(driver);
vm =virDomainFindByUUID(&driver->domains, dom->uuid);
if (!vm) {
- oneError(VIR_ERR_INVALID_DOMAIN, "%s",
+ oneError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto return_point;
}
@@ -316,7 +316,7 @@ static int oneDomainGetInfo(virDomainPtr dom,
oneDriverUnlock(driver);
if (!vm) {
- oneError(VIR_ERR_INVALID_DOMAIN, "%s",
+ oneError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
return -1;
}
@@ -391,7 +391,7 @@ static char *oneGetOSType(virDomainPtr dom)
vm =virDomainFindByUUID(&driver->domains, dom->uuid);
oneDriverUnlock(driver);
if (!vm) {
- oneError(VIR_ERR_INVALID_DOMAIN, "%s",
+ oneError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -420,7 +420,7 @@ static int oneDomainStartWithFlags(virDomainPtr dom, unsigned int flags)
vm = virDomainFindByName(&driver->domains, dom->name);
if (!vm) {
- oneError(VIR_ERR_INVALID_DOMAIN,
+ oneError(VIR_ERR_NO_DOMAIN,
_("no domain named %s"), dom->name);
goto return_point;
}
@@ -507,7 +507,7 @@ static int oneDomainShutdown(virDomainPtr dom)
oneDriverLock(driver);
if (!(vm=virDomainFindByID(&driver->domains, dom->id))) {
- oneError(VIR_ERR_INVALID_DOMAIN,
+ oneError(VIR_ERR_NO_DOMAIN,
_("no domain with id %d"), dom->id);
goto return_point;
}
@@ -542,7 +542,7 @@ static int oneDomainDestroy(virDomainPtr dom)
oneDriverLock(driver);
vm= virDomainFindByID(&driver->domains, dom->id);
if (!vm) {
- oneError(VIR_ERR_INVALID_DOMAIN,
+ oneError(VIR_ERR_NO_DOMAIN,
_("no domain with id %d"), dom->id);
goto return_point;
}
@@ -591,7 +591,7 @@ static int oneDomainSuspend(virDomainPtr dom)
oneError(VIR_ERR_OPERATION_INVALID, "%s",
_("domain is not running"));
} else {
- oneError(VIR_ERR_INVALID_DOMAIN,
+ oneError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
}
@@ -624,7 +624,7 @@ static int oneDomainResume(virDomainPtr dom)
oneError(VIR_ERR_OPERATION_INVALID, "%s",
_("domain is not paused"));
} else {
- oneError(VIR_ERR_INVALID_DOMAIN,
+ oneError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
}
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index a959ab6..7728981 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -350,7 +350,7 @@ static int openvzDomainGetInfo(virDomainPtr dom,
openvzDriverUnlock(driver);
if (!vm) {
- openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
+ openvzError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -437,7 +437,7 @@ static char *openvzDomainDumpXML(virDomainPtr dom, int flags) {
openvzDriverUnlock(driver);
if (!vm) {
- openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
+ openvzError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -481,7 +481,7 @@ static int openvzDomainSuspend(virDomainPtr dom) {
openvzDriverUnlock(driver);
if (!vm) {
- openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
+ openvzError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -521,7 +521,7 @@ static int openvzDomainResume(virDomainPtr dom) {
openvzDriverUnlock(driver);
if (!vm) {
- openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
+ openvzError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -561,7 +561,7 @@ static int openvzDomainShutdown(virDomainPtr dom) {
openvzDriverUnlock(driver);
if (!vm) {
- openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
+ openvzError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -599,7 +599,7 @@ static int openvzDomainReboot(virDomainPtr dom,
openvzDriverUnlock(driver);
if (!vm) {
- openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
+ openvzError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -1026,7 +1026,7 @@ openvzDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
openvzDriverUnlock(driver);
if (!vm) {
- openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
+ openvzError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching id"));
goto cleanup;
}
@@ -1073,7 +1073,7 @@ openvzDomainUndefine(virDomainPtr dom)
openvzDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
if (!vm) {
- openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
+ openvzError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -1117,7 +1117,7 @@ openvzDomainSetAutostart(virDomainPtr dom, int autostart)
openvzDriverUnlock(driver);
if (!vm) {
- openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
+ openvzError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -1149,7 +1149,7 @@ openvzDomainGetAutostart(virDomainPtr dom, int *autostart)
openvzDriverUnlock(driver);
if (!vm) {
- openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
+ openvzError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -1242,7 +1242,7 @@ static int openvzDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
openvzDriverUnlock(driver);
if (!vm) {
- openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
+ openvzError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 325b52b..92b5153 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -1310,7 +1310,7 @@ static int umlDomainShutdown(virDomainPtr dom) {
vm = virDomainFindByID(&driver->domains, dom->id);
umlDriverUnlock(driver);
if (!vm) {
- umlReportError(VIR_ERR_INVALID_DOMAIN,
+ umlReportError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
goto cleanup;
}
@@ -1340,7 +1340,7 @@ static int umlDomainDestroy(virDomainPtr dom) {
umlDriverLock(driver);
vm = virDomainFindByID(&driver->domains, dom->id);
if (!vm) {
- umlReportError(VIR_ERR_INVALID_DOMAIN,
+ umlReportError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
goto cleanup;
}
@@ -1370,7 +1370,7 @@ static char *umlDomainGetOSType(virDomainPtr dom) {
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
umlDriverUnlock(driver);
if (!vm) {
- umlReportError(VIR_ERR_INVALID_DOMAIN, "%s",
+ umlReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -1398,7 +1398,7 @@ static unsigned long umlDomainGetMaxMemory(virDomainPtr dom) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(dom->uuid, uuidstr);
- umlReportError(VIR_ERR_INVALID_DOMAIN,
+ umlReportError(VIR_ERR_NO_DOMAIN,
_("no domain with matching uuid '%s'"), uuidstr);
goto cleanup;
}
@@ -1423,7 +1423,7 @@ static int umlDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(dom->uuid, uuidstr);
- umlReportError(VIR_ERR_INVALID_DOMAIN,
+ umlReportError(VIR_ERR_NO_DOMAIN,
_("no domain with matching uuid '%s'"), uuidstr);
goto cleanup;
}
@@ -1456,7 +1456,7 @@ static int umlDomainSetMemory(virDomainPtr dom, unsigned long newmem) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(dom->uuid, uuidstr);
- umlReportError(VIR_ERR_INVALID_DOMAIN,
+ umlReportError(VIR_ERR_NO_DOMAIN,
_("no domain with matching uuid '%s'"), uuidstr);
goto cleanup;
}
@@ -1493,7 +1493,7 @@ static int umlDomainGetInfo(virDomainPtr dom,
umlDriverUnlock(driver);
if (!vm) {
- umlReportError(VIR_ERR_INVALID_DOMAIN, "%s",
+ umlReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -1533,7 +1533,7 @@ static char *umlDomainDumpXML(virDomainPtr dom,
umlDriverUnlock(driver);
if (!vm) {
- umlReportError(VIR_ERR_INVALID_DOMAIN, "%s",
+ umlReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -1584,7 +1584,7 @@ static int umlDomainStartWithFlags(virDomainPtr dom, unsigned int flags) {
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
if (!vm) {
- umlReportError(VIR_ERR_INVALID_DOMAIN, "%s",
+ umlReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -1650,7 +1650,7 @@ static int umlDomainUndefine(virDomainPtr dom) {
umlDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
if (!vm) {
- umlReportError(VIR_ERR_INVALID_DOMAIN, "%s",
+ umlReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -1922,7 +1922,7 @@ static int umlDomainGetAutostart(virDomainPtr dom,
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
if (!vm) {
- umlReportError(VIR_ERR_INVALID_DOMAIN, "%s",
+ umlReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -1948,7 +1948,7 @@ static int umlDomainSetAutostart(virDomainPtr dom,
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
if (!vm) {
- umlReportError(VIR_ERR_INVALID_DOMAIN, "%s",
+ umlReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -2022,7 +2022,7 @@ umlDomainBlockPeek(virDomainPtr dom,
umlDriverUnlock(driver);
if (!vm) {
- umlReportError(VIR_ERR_INVALID_DOMAIN, "%s",
+ umlReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index d931055..2b170ec 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -1453,7 +1453,7 @@ static int vboxDomainSuspend(virDomainPtr dom) {
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
goto cleanup;
}
@@ -1505,7 +1505,7 @@ static int vboxDomainResume(virDomainPtr dom) {
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
goto cleanup;
}
@@ -1556,7 +1556,7 @@ static int vboxDomainShutdown(virDomainPtr dom) {
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
goto cleanup;
}
@@ -1606,7 +1606,7 @@ static int vboxDomainReboot(virDomainPtr dom, unsigned int flags ATTRIBUTE_UNUSE
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
goto cleanup;
}
@@ -1652,7 +1652,7 @@ static int vboxDomainDestroy(virDomainPtr dom) {
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
goto cleanup;
}
@@ -1722,7 +1722,7 @@ static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) {
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
goto cleanup;
}
@@ -1950,11 +1950,11 @@ vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
}
VBOX_RELEASE(machine);
} else {
- vboxError(VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
}
} else {
- vboxError(VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_NO_DOMAIN,
_("can't open session to the domain with id %d"), dom->id);
}
data->vboxSession->vtbl->Close(data->vboxSession);
@@ -4863,7 +4863,7 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -5068,7 +5068,7 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) {
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -5340,7 +5340,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
vboxIIDFromUUID(&domiid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
@@ -5445,7 +5445,7 @@ vboxDomainSnapshotDumpXML(virDomainSnapshotPtr snapshot,
vboxIIDFromUUID(&domiid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
@@ -5549,7 +5549,7 @@ vboxDomainSnapshotNum(virDomainPtr dom,
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
@@ -5589,7 +5589,7 @@ vboxDomainSnapshotListNames(virDomainPtr dom,
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
@@ -5652,7 +5652,7 @@ vboxDomainSnapshotLookupByName(virDomainPtr dom,
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
@@ -5684,7 +5684,7 @@ vboxDomainHasCurrentSnapshot(virDomainPtr dom,
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
@@ -5724,7 +5724,7 @@ vboxDomainSnapshotCurrent(virDomainPtr dom,
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
@@ -5893,7 +5893,7 @@ vboxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
vboxIIDFromUUID(&domiid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
@@ -6050,7 +6050,7 @@ vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
vboxIIDFromUUID(&domiid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
--
1.7.0.4
2
2
Hello Radek,
what I am proposing is not closely related to libvirt, but solves your problem
configurable choice-by-choice.
I have a OpenSource-Project, which currently just uses commandline calls.
The utility therefore scans during each call either for available executables,
or uses configured pathnames from a configuration file for QEMU
and KVM.
What it does is e.g. the storage of automatically created configuration
files (created by ctys-createConfVM), which contains the actual call of the
executable, including the specific CPU-ARCH.
So you can install KVM support and QEMU with full scope of CPUs, and fix
within the defined ASCII configuration file to use a specific QEMU executable,
in addition the variant of the CPU. A too for the scan and check of actual
operation state for all available QEMU-executables and KVM(ctys-plugins) is
contained too.
The installed online-help is available too at:
http://www.UnifiedSessionsManager.org
http://www.unifiedsessionsmanager.eu/doc/en/html/doc.html
For various configuration Use-Cases related to QEMU/KVM refer to:
http://www.unifiedsessionsmanager.org/doc/en/html/man7/ctys-configuration-Q…
These comprise standard linux examples by KVM and embedded emulation
examples for:
->QEMU-arm-test
->QEMU-coldfire-test
->QNX-6.4.0
->Android
->MeeGo
The virlib is in current version just used by virsh for Xen.
Arno
----------------------------------------------------------------------------
Arno-Can Uestuensoez
www.i4p.com
-----Original Message-----
From: Radek Hladik [mailto:radek@eadresa.cz]
Sent: Monday, December 27, 2010 12:42 PM
To: libvirt-list(a)redhat.com
Subject: [libvirt] Kvm virtualization vs emulation
Wishing Merry Christmas to all.I am preparing new production host for libvirt and I did encounter one issue I am a little confused about. I am using libvirt 0.8.6 with qemu 0.13 (both built for F13 from F14 SRPMS). When I create domain with hvmlibvirt executes qemu-system-x86_64 with -enable-kvm option. The other host where I use libvirt 0.8.2 is running qemu-kvm for similar domain. The problem is that qemu-system with -enable-kvm is subjectively using qemu emulation instead of KVM full virtualization - there is nothing in log or so but the guest is slow and uses a lot of CPU for simple tasks. If I docp /usr/bin/qemu-kvm /usr/bin/qemu-system-x68_64the guest runs faster, uses less CPU on host, etc... Just booting RIPLinux is cca 3 times faster (about 10 secs vs 30).So my questions are:1) what is the logic of choosing which qemu-something to run?2) is there any way how to force libvirt to disable the qemu emulation at all? I'd prefer not to start domain that would not run with full virtualization at all. There is no requirement for emulation on this host and it is a huge waste of resources.3) Is there a way how to check qemu process if it is using the full virtualizaiton? As I understand it then KVM allows processes to use some sort of guest mode process (in addition to user mode and kernel mode) so I should be able to check it but I did not find out how.Radek--libvir-list mailing listlibvir-list@redhat.comhttps://www.redhat.com/mailman/listinfo/libvir-list
1
0
Wishing Merry Christmas to all.
I am preparing new production host for libvirt and I did encounter one
issue I am a little confused about. I am using libvirt 0.8.6 with qemu
0.13 (both built for F13 from F14 SRPMS). When I create domain with
<type arch='x86_64' machine='pc-0.13'>hvm</type>
libvirt executes qemu-system-x86_64 with -enable-kvm option. The other
host where I use libvirt 0.8.2 is running qemu-kvm for similar domain.
The problem is that qemu-system with -enable-kvm is subjectively using
qemu emulation instead of KVM full virtualization - there is nothing in
log or so but the guest is slow and uses a lot of CPU for simple tasks.
If I do
cp /usr/bin/qemu-kvm /usr/bin/qemu-system-x68_64
the guest runs faster, uses less CPU on host, etc... Just booting
RIPLinux is cca 3 times faster (about 10 secs vs 30).
So my questions are:
1) what is the logic of choosing which qemu-something to run?
2) is there any way how to force libvirt to disable the qemu emulation
at all? I'd prefer not to start domain that would not run with full
virtualization at all. There is no requirement for emulation on this
host and it is a huge waste of resources.
3) Is there a way how to check qemu process if it is using the full
virtualizaiton? As I understand it then KVM allows processes to use some
sort of guest mode process (in addition to user mode and kernel mode) so
I should be able to check it but I did not find out how.
Radek
1
0
Signed-off-by: MORITA Kazutaka <morita.kazutaka(a)lab.ntt.co.jp>
---
docs/formatdomain.html.in | 49 ++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 46 insertions(+), 3 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index cfd3451..86c2d0d 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -628,23 +628,39 @@
...
</serial>
</disk>
+ ...
+ <disk type='network'>
+ <driver name="qemu" type="raw"/>
+ <source protocol="sheepdog" name="image_name">
+ <host name="hostname" port="7000">
+ </source>
+ <target dev="hdb" bus="ide"/>
+ </disk>
</devices>
...</pre>
<dl>
<dt><code>disk</code></dt>
<dd>The <code>disk</code> element is the main container for describing
- disks. The <code>type</code> attribute is either "file" or "block"
+ disks. The <code>type</code> attribute is either "file", "block", "dir", or "network"
and refers to the underlying source for the disk. The optional
<code>device</code> attribute indicates how the disk is to be exposed
to the guest OS. Possible values for this attribute are "floppy", "disk"
and "cdrom", defaulting to "disk".
- <span class="since">Since 0.0.3; "device" attribute since 0.1.4</span></dd>
+ <span class="since">Since 0.0.3; "device" attribute since 0.1.4;
+ "network" attribute value since after 0.8.6 (QEMU and KVM only)</span></dd>
<dt><code>source</code></dt>
<dd>If the disk <code>type</code> is "file", then the <code>file</code> attribute
specifies the fully-qualified path to the file holding the disk. If the disk
<code>type</code> is "block", then the <code>dev</code> attribute specifies
- the path to the host device to serve as the disk. <span class="since">Since 0.0.3</span></dd>
+ the path to the host device to serve as the disk. If the disk <code>type</code>
+ is "network", then the <code>protocol</code> attribute specifies the protocol
+ to access to the requested image; possible values are "nbd", "rbd", and "sheepdog".
+ If the <code>protocol</code> attribute is "rbd" or "sheepdog", an additional
+ attribute <code>name</code> is mandatory to specify which image to be used.
+ When the disk <code>type</code> is "network", the <code>source</code> may have
+ zero or more <code>host</code> sub-elements used to specify the hosts to connect.
+ <span class="since">Since 0.0.3</span></dd>
<dt><code>target</code></dt>
<dd>The <code>target</code> element controls the bus / device under which the
disk is exposed to the guest OS. The <code>dev</code> attribute indicates
@@ -680,6 +696,33 @@
For example, it may look as <code><serial>WD-WMAP9A966149</serial></code>.
<span class="since">Since 0.7.1</span>
</dd>
+ <dt><code>host</code></dt>
+ <dd>The <code>host</code> element has two attributes "name" and "port",
+ which specify the hostname and the port number. The meaning of this
+ element and the number of the elements depend on the protocol attribute.
+ <table class="top_table">
+ <tr>
+ <th> Protocol </th>
+ <th> Meaning </th>
+ <th> Number of hosts </th>
+ </tr>
+ <tr>
+ <td> nbd </td>
+ <td> a server running nbd-server </td>
+ <td> only one </td>
+ </tr>
+ <tr>
+ <td> rbd </td>
+ <td> monitor servers of RBD </td>
+ <td> one or more </td>
+ </tr>
+ <tr>
+ <td> sheepdog </td>
+ <td> one of the sheepdog servers (default is localhost:7000) </td>
+ <td> zero or one </td>
+ </tr>
+ </table>
+ </dd>
</dl>
<h4><a name="elementsUSB">USB and PCI devices</a></h4>
--
1.7.1
2
1
[libvirt] [PATCH] build: fix building error when building without libvirtd
by Wen Congyang 24 Dec '10
by Wen Congyang 24 Dec '10
24 Dec '10
When I build libvirt without libvirtd, I receive some errors:
cp: cannot stat `/home/wency/rpmbuild/BUILDROOT/libvirt-0.8.6-1.el6.x86_64/etc/libvirt/qemu/networks/default.xml': No such file or directory
My build step:
# ./autogen.sh --without-libvirtd
# make dist
# rpmbuild --nodeps --define "_sourcedir `pwd`" --define "_without_libvirtd 1" -ba libvirt.spec
The reason is we disable network when we do not build libvirt daemon in configure.ac.
After fixing this bug, I build libvirt without libvirtd, I receive other errors:
RPM build errors:
Installed (but unpackaged) file(s) found:
/usr/share/doc/libvirt-0.8.6/html/32favicon.png
/usr/share/doc/libvirt-0.8.6/html/api.html
...
Signed-off-by: Wen Congyang <wency(a)cn.fujitsu.com>
---
libvirt.spec.in | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 7c60eba..2b50e94 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -188,6 +188,12 @@
%endif
+# there's no use compiling the network driver without
+# the libvirt daemon
+%if ! %{with_libvirtd}
+%define with_network 0
+%endif
+
Summary: Library providing a simple virtualization API
Name: libvirt
Version: @VERSION@
@@ -667,6 +673,8 @@ rm -rf $RPM_BUILD_ROOT%{_datadir}/doc/libvirt-%{version}
%if ! %{with_libvirtd}
rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/nwfilter
+mv $RPM_BUILD_ROOT%{_datadir}/doc/libvirt-%{version}/html \
+ $RPM_BUILD_ROOT%{_datadir}/doc/libvirt-devel-%{version}/
%endif
%if ! %{with_qemu}
--
1.7.1
2
1
If the memory of guest OS is changed constantly, the live migration
can not be ended ever for ever.
We can use the command 'virsh migrate-setmaxdowntime' to control the
live migration. But the value of maxdowntime is diffcult to calculate
because it depends on the transfer speed of network and constantly
changing memroy size. We need a easy way to control the live migration.
This patch set add the support of auto cold migration fallback on
timeout. With this patch set, when we migrate the guest OS, we can
specify a timeout. If the live migration timeouts, the migration will
fallback to cold migration.
Test of this patchset on Linux:
Env:
a. The size of guest OS's memory: 1GB
b. The transfer speed of network: about 100Mb/s
c. The size of constantly changing memory: more than 900MB
1. migrate without timeout
# virsh migrate --live RHEL6RC qemu+ssh://<dest IP>/system tcp://<dest IP>:49152
The migration does not end after 12 hours.
2. migrate with timeout(30 minutes):
# virsh -t migrate --live --timeout 1800 RHEL6RC qemu+ssh://<dest IP>/system tcp:<dest IP>:49152
(Time: 1828615.523 ms)
v4:
- move tools/timer.* into src/util/ directory
- use
v3:
- use the existing virEventXXXTimeout() APT to implement timer
- merge Add, Update, Delete into one single interface virSetTimeout()
- start timer thread when initializing timer
v2:
- implement timer for Windows
- implement dynamic timers
Wen Congyang (3):
move daemon/event.* into src/util/ directory
timer impl
force guest to suspend at timeout
cfg.mk | 1 +
daemon/Makefile.am | 1 -
daemon/event.c | 700 ----------------------------------------------
daemon/event.h | 134 ---------
daemon/libvirtd.c | 2 +-
src/Makefile.am | 4 +-
src/libvirt.c | 2 +
src/libvirt_private.syms | 20 ++
src/util/event_impl.c | 700 ++++++++++++++++++++++++++++++++++++++++++++++
src/util/event_impl.h | 134 +++++++++
src/util/timer.c | 159 +++++++++++
src/util/timer.h | 34 +++
tests/Makefile.am | 2 +-
tests/eventtest.c | 2 +-
tools/Makefile.am | 1 -
tools/console.c | 2 +-
tools/virsh.c | 69 +++++-
tools/virsh.pod | 4 +
18 files changed, 1129 insertions(+), 842 deletions(-)
delete mode 100644 daemon/event.c
delete mode 100644 daemon/event.h
create mode 100644 src/util/event_impl.c
create mode 100644 src/util/event_impl.h
create mode 100644 src/util/timer.c
create mode 100644 src/util/timer.h
2
5
When I run configure, I receive some syntax error.
# ./configure --without-xenapi --without-xen
......
checking where to find <rpc/rpc.h>... none
checking for library containing dlopen... -ldl
./configure: line 52500: test: =: unary operator expected
./configure: line 52766: test: =: unary operator expected
checking linux/kvm.h usability... yes
checking linux/kvm.h presence... yes
......
Signed-off-by: Wen Congyang <wency(a)cn.fujitsu.com>
---
configure.ac | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/configure.ac b/configure.ac
index 51da1b0..377b9c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -430,6 +430,7 @@ old_CFLAGS="$CFLAGS"
LIBXENSERVER_LIBS=""
LIBXENSERVER_CFLAGS=""
dnl search for the XenServer library
+fail=0
if test "$with_xenapi" != "no" ; then
if test "$with_xenapi" != "yes" && test "$with_xenapi" != "check" ; then
LIBXENSERVER_CFLAGS="-I$with_xenapi/include"
--
1.7.1
2
2
Add VM name/UUID in log for domain related APIs.
Format: "param0=%p, param1=%p, (VM: %s)"
* src/libvirt.c
---
src/libvirt.c | 294 +++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 221 insertions(+), 73 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index ee2495a..03dcafc 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -1961,7 +1961,9 @@ error:
virConnectPtr
virDomainGetConnect (virDomainPtr dom)
{
- DEBUG("dom=%p", dom);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("dom=%p, (VM: %s)", dom, name);
virResetLastError();
@@ -2100,7 +2102,10 @@ error:
virDomainPtr
virDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
{
- DEBUG("conn=%p, uuid=%s", conn, uuid);
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+ virUUIDFormat(uuid, uuidstr);
+
+ DEBUG("conn=%p, uuid=%s", conn, uuidstr);
virResetLastError();
@@ -2226,8 +2231,9 @@ int
virDomainDestroy(virDomainPtr domain)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(domain);
- DEBUG("domain=%p", domain);
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -2270,7 +2276,9 @@ error:
int
virDomainFree(virDomainPtr domain)
{
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -2306,13 +2314,15 @@ virDomainFree(virDomainPtr domain)
int
virDomainRef(virDomainPtr domain)
{
+ const char *name = virDomainGetName(domain);
+
if ((!VIR_IS_CONNECTED_DOMAIN(domain))) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virDispatchError(NULL);
return(-1);
}
virMutexLock(&domain->conn->lock);
- DEBUG("domain=%p refs=%d", domain, domain->refs);
+ DEBUG("domain=%p, refs=%d, (VM: %s)", domain, domain->refs, name);
domain->refs++;
virMutexUnlock(&domain->conn->lock);
return 0;
@@ -2335,7 +2345,9 @@ int
virDomainSuspend(virDomainPtr domain)
{
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -2380,7 +2392,9 @@ int
virDomainResume(virDomainPtr domain)
{
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -2428,7 +2442,9 @@ virDomainSave(virDomainPtr domain, const char *to)
{
char filepath[4096];
virConnectPtr conn;
- DEBUG("domain=%p, to=%s", domain, to);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, to=%s, (VM: %s)", domain, to, name);
virResetLastError();
@@ -2570,7 +2586,9 @@ virDomainCoreDump(virDomainPtr domain, const char *to, int flags)
{
char filepath[4096];
virConnectPtr conn;
- DEBUG("domain=%p, to=%s, flags=%d", domain, to, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, to=%s, flags=%d, (VM: %s)", domain, to, flags, name);
virResetLastError();
@@ -2647,7 +2665,9 @@ int
virDomainShutdown(virDomainPtr domain)
{
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -2693,7 +2713,9 @@ int
virDomainReboot(virDomainPtr domain, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, flags=%u", domain, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, flags=%u, (VM: %s)", domain, flags, name);
virResetLastError();
@@ -2760,7 +2782,9 @@ virDomainGetName(virDomainPtr domain)
int
virDomainGetUUID(virDomainPtr domain, unsigned char *uuid)
{
- DEBUG("domain=%p, uuid=%p", domain, uuid);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, uuid=%p, (VM: %s)", domain, uuid, name);
virResetLastError();
@@ -2794,7 +2818,9 @@ int
virDomainGetUUIDString(virDomainPtr domain, char *buf)
{
unsigned char uuid[VIR_UUID_BUFLEN];
- DEBUG("domain=%p, buf=%p", domain, buf);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, buf=%p, (VM: %s)", domain, buf, name);
virResetLastError();
@@ -2830,7 +2856,9 @@ error:
unsigned int
virDomainGetID(virDomainPtr domain)
{
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -2855,7 +2883,9 @@ char *
virDomainGetOSType(virDomainPtr domain)
{
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -2896,7 +2926,9 @@ unsigned long
virDomainGetMaxMemory(virDomainPtr domain)
{
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -2942,7 +2974,9 @@ int
virDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
{
virConnectPtr conn;
- DEBUG("domain=%p, memory=%lu", domain, memory);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, memory=%lu, (VM: %s)", domain, memory, name);
virResetLastError();
@@ -2995,7 +3029,9 @@ int
virDomainSetMemory(virDomainPtr domain, unsigned long memory)
{
virConnectPtr conn;
- DEBUG("domain=%p, memory=%lu", domain, memory);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, memory=%lu, (VM: %s)", domain, memory, name);
virResetLastError();
@@ -3049,7 +3085,10 @@ virDomainSetMemoryParameters(virDomainPtr domain,
int nparams, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, params=%p, nparams=%d, flags=%u", domain, params, nparams, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, params=%p, nparams=%d, flags=%u, (VM: %s)",
+ domain, params, nparams, flags, name);
virResetLastError();
@@ -3123,7 +3162,11 @@ virDomainGetMemoryParameters(virDomainPtr domain,
int *nparams, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, params=%p, nparams=%d, flags=%u", domain, params, (nparams)?*nparams:-1, flags);
+
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, params=%p, nparams=%d, flags=%u, (VM: %s)",
+ domain, params, (nparams)?*nparams:-1, flags, name);
virResetLastError();
@@ -3167,7 +3210,9 @@ int
virDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
{
virConnectPtr conn;
- DEBUG("domain=%p, info=%p", domain, info);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, info=%p, (VM: %s)", domain, info, name);
virResetLastError();
@@ -3215,7 +3260,9 @@ char *
virDomainGetXMLDesc(virDomainPtr domain, int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, flags=%d", domain, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, flags=%d, (VM: %s)", domain, flags, name);
virResetLastError();
@@ -3662,8 +3709,10 @@ virDomainMigrate (virDomainPtr domain,
unsigned long bandwidth)
{
virDomainPtr ddomain = NULL;
- DEBUG("domain=%p, dconn=%p, flags=%lu, dname=%s, uri=%s, bandwidth=%lu",
- domain, dconn, flags, NULLSTR(dname), NULLSTR(uri), bandwidth);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, dconn=%p, flags=%lu, dname=%s, uri=%s, bandwidth=%lu, (VM: %s)",
+ domain, dconn, flags, NULLSTR(dname), NULLSTR(uri), bandwidth, name);
virResetLastError();
@@ -3811,8 +3860,10 @@ virDomainMigrateToURI (virDomainPtr domain,
const char *dname,
unsigned long bandwidth)
{
- DEBUG("domain=%p, duri=%p, flags=%lu, dname=%s, bandwidth=%lu",
- domain, NULLSTR(duri), flags, NULLSTR(dname), bandwidth);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, duri=%p, flags=%lu, dname=%s, bandwidth=%lu, (VM: %s)",
+ domain, NULLSTR(duri), flags, NULLSTR(dname), bandwidth, name);
virResetLastError();
@@ -3924,9 +3975,11 @@ virDomainMigratePerform (virDomainPtr domain,
unsigned long bandwidth)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(domain);
+
VIR_DEBUG("domain=%p, cookie=%p, cookielen=%d, uri=%s, flags=%lu, "
- "dname=%s, bandwidth=%lu", domain, cookie, cookielen, uri, flags,
- NULLSTR(dname), bandwidth);
+ "dname=%s, bandwidth=%lu, (VM: %s)", domain, cookie,
+ cookielen, uri, flags, NULLSTR(dname), bandwidth, name);
virResetLastError();
@@ -4290,7 +4343,9 @@ virDomainGetSchedulerType(virDomainPtr domain, int *nparams)
{
virConnectPtr conn;
char *schedtype;
- DEBUG("domain=%p, nparams=%p", domain, nparams);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, nparams=%p, (VM: %s)", domain, nparams, name);
virResetLastError();
@@ -4335,7 +4390,10 @@ virDomainGetSchedulerParameters(virDomainPtr domain,
virSchedParameterPtr params, int *nparams)
{
virConnectPtr conn;
- DEBUG("domain=%p, params=%p, nparams=%p", domain, params, nparams);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, params=%p, nparams=%p, (VM: %s)", domain,
+ params, nparams, name);
virResetLastError();
@@ -4378,7 +4436,10 @@ virDomainSetSchedulerParameters(virDomainPtr domain,
virSchedParameterPtr params, int nparams)
{
virConnectPtr conn;
- DEBUG("domain=%p, params=%p, nparams=%d", domain, params, nparams);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, params=%p, nparams=%d, (VM: %s)", domain,
+ params, nparams, name);
virResetLastError();
@@ -4438,7 +4499,10 @@ virDomainBlockStats (virDomainPtr dom, const char *path,
{
virConnectPtr conn;
struct _virDomainBlockStats stats2 = { -1, -1, -1, -1, -1 };
- DEBUG("domain=%p, path=%s, stats=%p, size=%zi", dom, path, stats, size);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("domain=%p, path=%s, stats=%p, size=%zi, (VM: %s)", dom,
+ path, stats, size, name);
virResetLastError();
@@ -4496,7 +4560,10 @@ virDomainInterfaceStats (virDomainPtr dom, const char *path,
virConnectPtr conn;
struct _virDomainInterfaceStats stats2 = { -1, -1, -1, -1,
-1, -1, -1, -1 };
- DEBUG("domain=%p, path=%s, stats=%p, size=%zi", dom, path, stats, size);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("domain=%p, path=%s, stats=%p, size=%zi, (VM: %s)", dom,
+ path, stats, size, name);
virResetLastError();
@@ -4561,7 +4628,9 @@ int virDomainMemoryStats (virDomainPtr dom, virDomainMemoryStatPtr stats,
{
virConnectPtr conn;
unsigned long nr_stats_ret = 0;
- DEBUG("domain=%p, stats=%p, nr_stats=%u", dom, stats, nr_stats);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("domain=%p, stats=%p, nr_stats=%u, (VM: %s)", dom, stats, nr_stats, name);
if (flags != 0) {
virLibDomainError (dom, VIR_ERR_INVALID_ARG,
@@ -4645,8 +4714,10 @@ virDomainBlockPeek (virDomainPtr dom,
unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, path=%s, offset=%lld, size=%zi, buffer=%p",
- dom, path, offset, size, buffer);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("domain=%p, path=%s, offset=%lld, size=%zi, buffer=%p, (VM: %s)",
+ dom, path, offset, size, buffer, name);
virResetLastError();
@@ -4736,8 +4807,10 @@ virDomainMemoryPeek (virDomainPtr dom,
unsigned int flags)
{
virConnectPtr conn;
- DEBUG ("domain=%p, start=%lld, size=%zi, buffer=%p, flags=%d",
- dom, start, size, buffer, flags);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG ("domain=%p, start=%lld, size=%zi, buffer=%p, flags=%d, (VM: %s)",
+ dom, start, size, buffer, flags, name);
virResetLastError();
@@ -4821,7 +4894,9 @@ int
virDomainGetBlockInfo(virDomainPtr domain, const char *path, virDomainBlockInfoPtr info, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, info=%p flags=%u", domain, info, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, info=%p flags=%u, (VM: %s)", domain, info, flags, name);
virResetLastError();
@@ -4919,7 +4994,11 @@ error:
int
virDomainUndefine(virDomainPtr domain) {
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name;
+
+ name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -5041,7 +5120,9 @@ error:
int
virDomainCreate(virDomainPtr domain) {
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM :%s)", domain, name);
virResetLastError();
@@ -5084,7 +5165,9 @@ error:
int
virDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) {
virConnectPtr conn;
- DEBUG("domain=%p, flags=%d", domain, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, flags=%d, (VM: %s)", domain, flags, name);
virResetLastError();
@@ -5130,7 +5213,9 @@ virDomainGetAutostart(virDomainPtr domain,
int *autostart)
{
virConnectPtr conn;
- DEBUG("domain=%p, autostart=%p", domain, autostart);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, autostart=%p, (VM: %s)", domain, autostart, name);
virResetLastError();
@@ -5176,7 +5261,9 @@ virDomainSetAutostart(virDomainPtr domain,
int autostart)
{
virConnectPtr conn;
- DEBUG("domain=%p, autostart=%d", domain, autostart);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, autostart=%d, (VM: %s)", domain, autostart, name);
virResetLastError();
@@ -5230,7 +5317,9 @@ int
virDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
{
virConnectPtr conn;
- DEBUG("domain=%p, nvcpus=%u", domain, nvcpus);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, nvcpus=%u, (VM: %s)", domain, nvcpus, name);
virResetLastError();
@@ -5296,7 +5385,10 @@ virDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, nvcpus=%u, flags=%u", domain, nvcpus, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, nvcpus=%u, flags=%u, (VM: %s)", domain,
+ nvcpus, flags, name);
virResetLastError();
@@ -5359,7 +5451,9 @@ int
virDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, flags=%u", domain, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, flags=%u, (VM: %s)", domain, flags, name);
virResetLastError();
@@ -5417,7 +5511,10 @@ virDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
unsigned char *cpumap, int maplen)
{
virConnectPtr conn;
- DEBUG("domain=%p, vcpu=%u, cpumap=%p, maplen=%d", domain, vcpu, cpumap, maplen);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, vcpu=%u, cpumap=%p, maplen=%d, (VM: %s)",
+ domain, vcpu, cpumap, maplen, name);
virResetLastError();
@@ -5480,7 +5577,10 @@ virDomainGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
unsigned char *cpumaps, int maplen)
{
virConnectPtr conn;
- DEBUG("domain=%p, info=%p, maxinfo=%d, cpumaps=%p, maplen=%d", domain, info, maxinfo, cpumaps, maplen);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, info=%p, maxinfo=%d, cpumaps=%p, maplen=%d, (VM: %s)",
+ domain, info, maxinfo, cpumaps, maplen, name);
virResetLastError();
@@ -5536,7 +5636,9 @@ int
virDomainGetMaxVcpus(virDomainPtr domain)
{
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -5665,7 +5767,9 @@ int
virDomainAttachDevice(virDomainPtr domain, const char *xml)
{
virConnectPtr conn;
- DEBUG("domain=%p, xml=%s", domain, xml);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, xml=%s, (VM: %s)", domain, xml, name);
virResetLastError();
@@ -5724,7 +5828,9 @@ virDomainAttachDeviceFlags(virDomainPtr domain,
const char *xml, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, xml=%s, flags=%d", domain, xml, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, xml=%s, flags=%d, (VM: %s)", domain, xml, flags, name);
virResetLastError();
@@ -5767,7 +5873,9 @@ int
virDomainDetachDevice(virDomainPtr domain, const char *xml)
{
virConnectPtr conn;
- DEBUG("domain=%p, xml=%s", domain, xml);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, xml=%s, (VM: %s)", domain, xml, name);
virResetLastError();
@@ -5822,7 +5930,11 @@ virDomainDetachDeviceFlags(virDomainPtr domain,
const char *xml, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, xml=%s, flags=%d", domain, xml, flags);
+ const char *name;
+
+ name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, xml=%s, flags=%d, (VM: %s)", domain, xml, flags, name);
virResetLastError();
@@ -5880,7 +5992,9 @@ virDomainUpdateDeviceFlags(virDomainPtr domain,
const char *xml, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, xml=%s, flags=%d", domain, xml, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, xml=%s, flags=%d, (VM: %s)", domain, xml, flags, name);
virResetLastError();
@@ -6206,7 +6320,10 @@ error:
virNetworkPtr
virNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
{
- DEBUG("conn=%p, uuid=%s", conn, uuid);
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+ virUUIDFormat(uuid, uuidstr);
+
+ DEBUG("conn=%p, uuid=%s", conn, uuidstr);
virResetLastError();
@@ -11431,7 +11548,9 @@ error:
*/
int virDomainIsPersistent(virDomainPtr dom)
{
- DEBUG("dom=%p", dom);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("domain=%p, (VM: %s)", dom, name);
virResetLastError();
@@ -11464,7 +11583,9 @@ error:
*/
int virDomainIsUpdated(virDomainPtr dom)
{
- DEBUG("dom=%p", dom);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("domain=%p, (VM: %s)", dom, name);
virResetLastError();
@@ -12353,7 +12474,9 @@ int
virDomainGetJobInfo(virDomainPtr domain, virDomainJobInfoPtr info)
{
virConnectPtr conn;
- DEBUG("domain=%p, info=%p", domain, info);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, info=%p, (VM: %s)", domain, info, name);
virResetLastError();
@@ -12401,8 +12524,9 @@ int
virDomainAbortJob(virDomainPtr domain)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(domain);
- DEBUG("domain=%p", domain);
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -12452,8 +12576,10 @@ virDomainMigrateSetMaxDowntime(virDomainPtr domain,
unsigned int flags)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(domain);
- DEBUG("domain=%p, downtime=%llu, flags=%u", domain, downtime, flags);
+ DEBUG("domain=%p, downtime=%llu, flags=%u, (VM: %s)", domain,
+ downtime, flags, name);
virResetLastError();
@@ -12522,7 +12648,12 @@ virConnectDomainEventRegisterAny(virConnectPtr conn,
void *opaque,
virFreeCallback freecb)
{
- DEBUG("conn=%p dom=%p, eventID=%d, cb=%p, opaque=%p, freecb=%p", conn, dom, eventID, cb, opaque, freecb);
+ const char *name;
+
+ name = virDomainGetName(dom);
+
+ DEBUG("conn=%p, domain=%p, eventID=%d, cb=%p, opaque=%p, freecb=%p, (VM: %s)",
+ conn, dom, eventID, cb, opaque, freecb, name);
virResetLastError();
if (!VIR_IS_CONNECT(conn)) {
@@ -12614,8 +12745,9 @@ error:
int virDomainManagedSave(virDomainPtr dom, unsigned int flags)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(dom);
- VIR_DEBUG("dom=%p, flags=%u", dom, flags);
+ VIR_DEBUG("dom%p, flags=%u, (VM: %s)", dom, flags, name);
virResetLastError();
@@ -12662,8 +12794,9 @@ error:
int virDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(dom);
- VIR_DEBUG("dom=%p, flags=%u", dom, flags);
+ VIR_DEBUG("dom=%p, flags=%u, (VM: %s)", dom, flags, name);
virResetLastError();
@@ -12703,8 +12836,9 @@ error:
int virDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(dom);
- VIR_DEBUG("dom=%p, flags=%u", dom, flags);
+ VIR_DEBUG("dom=%p, flags=%u, (VM: %s)", dom, flags, name);
virResetLastError();
@@ -12753,8 +12887,9 @@ virDomainSnapshotCreateXML(virDomainPtr domain,
unsigned int flags)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(domain);
- DEBUG("domain=%p, xmlDesc=%s, flags=%u", domain, xmlDesc, flags);
+ DEBUG("domain=%p, xmlDesc=%s, flags=%u, (VM: %s)", domain, xmlDesc, flags, name);
virResetLastError();
@@ -12845,7 +12980,9 @@ int
virDomainSnapshotNum(virDomainPtr domain, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -12887,9 +13024,10 @@ virDomainSnapshotListNames(virDomainPtr domain, char **names, int nameslen,
unsigned int flags)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(domain);
- DEBUG("domain=%p, names=%p, nameslen=%d, flags=%u",
- domain, names, nameslen, flags);
+ DEBUG("domain=%p, names=%p, nameslen=%d, flags=%u, (VM: %s)",
+ domain, names, nameslen, flags, name);
virResetLastError();
@@ -12938,7 +13076,10 @@ virDomainSnapshotLookupByName(virDomainPtr domain,
unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, name=%s, flags=%u", domain, name, flags);
+ const char *domname = virDomainGetName(domain);
+
+ DEBUG("domain=%p, name=%s, flags=%u, (VM: %s)", domain, name,
+ flags, domname);
virResetLastError();
@@ -12982,7 +13123,9 @@ int
virDomainHasCurrentSnapshot(virDomainPtr domain, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, flags=%u", domain, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, flags=%u, (VM: %s)", domain, flags, name);
virResetLastError();
@@ -13023,7 +13166,9 @@ virDomainSnapshotCurrent(virDomainPtr domain,
unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, flags=%u", domain, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, flags=%u, (VM: %s)", domain, flags, name);
virResetLastError();
@@ -13187,7 +13332,10 @@ int virDomainOpenConsole(virDomainPtr dom,
unsigned int flags)
{
virConnectPtr conn;
- DEBUG("dom=%p devname=%s, st=%p flags=%u", dom, NULLSTR(devname), st, flags);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("dom=%p, devname=%s, st=%p, flags=%u, (VM: %s)", dom,
+ NULLSTR(devname), st, flags, name);
virResetLastError();
--
1.7.3.2
3
4
Hello all,
as some of you may have noticed, I'm back online, just in a very
different timezone now !
I'm still behind on reading the list emails but a lot of the changes
in the last month have been refactoring and cleanups, and maybe we ought
to make a new release at the end of the month to try to catch possible
regressions introduced as early as possible. What do people think of a new
release for the new year, which would mean entering freeze over the
week-end. My own testing will probably be limited as most of my machines
are in boxes in a container somewhere, but I should be able to make
a release :-)
Also on the release name, should we go 0.9.0 considering the refactorings
(i.e. indicating future patches will be harder to apply to earlier branches)
or stick to 0.8.7 (considering that there isn't major feature improvement
... unless I missed them !),
Opinions ?
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
6
16
23 Dec '10
From: Daniel P. Berrange <berrange(a)redhat.com>
A number of the libvirt APIs require the use of cgroups. This is not
enabled by default on a RHEL6 install. After discussion with cgroups
team, it was decided that upon installation of the libvirt RPM, we
should automatically turn on the cgroups service. This will activate a
default configuration that turns on all cgroups controllers libvirt
requires for full operation.
---
libvirt.spec.in | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 7c60eba..5ea3422 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -68,6 +68,7 @@
%define with_libnl 0%{!?_without_libnl:0}
%define with_audit 0%{!?_without_audit:0}
%define with_dtrace 0%{!?_without_dtrace:0}
+%define with_cgconfig 0%{!?_without_cgconfig:0}
# Non-server/HV driver defaults which are always enabled
%define with_python 0%{!?_without_python:1}
@@ -169,6 +170,13 @@
%define with_dtrace 1
%endif
+# Pull in cgroups config system
+%if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
+%if %{with_qemu} || %{with_lxc}
+%define with_cgconfig 0%{!?_without_cgconfig:1}
+%endif
+%endif
+
# Force QEMU to run as non-root
%if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
%define qemu_user qemu
@@ -271,6 +279,9 @@ Requires: parted
# For multipath support
Requires: device-mapper
%endif
+%if %{with_cgconfig}
+Requires: libcgroup
+%endif
%if %{with_xen}
BuildRequires: xen-devel
%endif
@@ -725,6 +736,12 @@ then
fi
%endif
+%if %{with_cgconfig}
+if [ "$1" -eq "1" ]; then
+/sbin/chkconfig cgconfig on
+fi
+%endif
+
/sbin/chkconfig --add libvirtd
if [ "$1" -ge "1" ]; then
/sbin/service libvirtd condrestart > /dev/null 2>&1
--
1.7.3.4
3
3
---
libvirt.spec.in | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 5ea3422..fd99a54 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -87,7 +87,7 @@
%define with_numactl 0
%endif
-# RHEL doesn't ship OpenVZ, VBox, UML, OpenNebula, PowerHypervisor, ESX,
+# RHEL doesn't ship OpenVZ, VBox, UML, OpenNebula, PowerHypervisor,
# VMWare, or libxenserver (xenapi)
%if 0%{?rhel}
%define with_openvz 0
@@ -95,7 +95,6 @@
%define with_uml 0
%define with_one 0
%define with_phyp 0
-%define with_esx 0
%define with_vmware 0
%define with_xenapi 0
%endif
--
1.7.3.4
2
4
qemudOpenAsUID is intended to open a file with the credentials of a
specified uid. Current implementation fails if the file is accessible to
one of uid's groups but not owned by uid.
This patch replaces the supplementary group list that the child process
inherited from libvirtd with the default group list of uid.
---
src/qemu/qemu_driver.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0ce2d40..a1027d4 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6353,6 +6353,7 @@ parent_cleanup:
char *buf = NULL;
size_t bufsize = 1024 * 1024;
int bytesread;
+ struct passwd *pwd;
/* child doesn't need the read side of the pipe */
close(pipefd[0]);
@@ -6365,6 +6366,21 @@ parent_cleanup:
goto child_cleanup;
}
+ /* we can avoid getpwuid_r() in threadless child */
+ if ((pwd = getpwuid(uid)) == NULL) {
+ exit_code = errno;
+ virReportSystemError(errno,
+ _("cannot setuid(%d) to read '%s'"),
+ uid, path);
+ goto child_cleanup;
+ }
+ if (initgroups(pwd->pw_name, pwd->pw_gid) != 0) {
+ exit_code = errno;
+ virReportSystemError(errno,
+ _("cannot setuid(%d) to read '%s'"),
+ uid, path);
+ goto child_cleanup;
+ }
if (setuid(uid) != 0) {
exit_code = errno;
virReportSystemError(errno,
--
1.7.2.3
5
21
[libvirt] [PATCH] spec: Really skip tests that don't work in mock build root
by Jiri Denemark 23 Dec '10
by Jiri Denemark 23 Dec '10
23 Dec '10
Two of the tests we want to skip are C tests and since we moved
compiling tests to make check phase, replacing compiled binary with a
no-op shell script before running make check doesn't really work for
them. We need to replace the source of such tests.
---
libvirt.spec.in | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index fd99a54..3889f5d 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -700,8 +700,12 @@ cd tests
for i in nodeinfotest daemon-conf seclabeltest
do
rm -f $i
- printf "#!/bin/sh\nexit 0\n" > $i
- chmod +x $i
+ if [ -f $i.c ]; then
+ echo 'int main(void) { return 0; }' > $i.c
+ else
+ printf "#!/bin/sh\nexit 0\n" > $i
+ chmod +x $i
+ fi
done
make check
--
1.7.3.4
2
2
[libvirt] [PATCH] docs: Make VMware Workstation / Player page appear in the menu
by Matthias Bolte 23 Dec '10
by Matthias Bolte 23 Dec '10
23 Dec '10
By adding it to sitemap.html.in. Also <ul> can't be nested in <p>.
---
docs/drvvmware.html.in | 4 +++-
docs/sitemap.html.in | 4 ++++
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/docs/drvvmware.html.in b/docs/drvvmware.html.in
index 273e0a0..0ef6044 100644
--- a/docs/drvvmware.html.in
+++ b/docs/drvvmware.html.in
@@ -1,6 +1,6 @@
<html>
<body>
- <h1>VMware Workstation/Player hypervisors driver</h1>
+ <h1>VMware Workstation / Player hypervisors driver</h1>
<p>
The libvirt VMware Workstation driver should be able to manage any Workstation and
Player version supported by the VMware VIX API. See the compatibility list
@@ -15,10 +15,12 @@
<p>
The libvirt VMware driver provides per-user drivers (the "session" instance).
Two uris are available:
+ </p>
<ul>
<li>"vmwareplayer" for VMware Player</li>
<li>"vmwarews" for VMware Workstation</li>
</ul>
+ <p>
Some example connection URIs for the driver are:
</p>
diff --git a/docs/sitemap.html.in b/docs/sitemap.html.in
index 63e420f..490450e 100644
--- a/docs/sitemap.html.in
+++ b/docs/sitemap.html.in
@@ -192,6 +192,10 @@
<a href="drvesx.html">VMware ESX</a>
<span>Driver for VMware ESX</span>
</li>
+ <li>
+ <a href="drvvmware.html">VMware Workstation / Player</a>
+ <span>Driver for VMware Workstation / Player</span>
+ </li>
</ul>
</li>
<li>
--
1.7.0.4
2
2
23 Dec '10
Shorten qemuDomainSnapshotWriteSnapshotMetadata function name
and make it take a snapshot pointer instead of dealing with
the current snapshot. Update other functions accordingly.
Add a qemuDomainSnapshotReparentChildren hash iterator to
reparent the children of a snapshot that is being deleted. Use
qemuDomainSnapshotWriteMetadata to write updated metadata
to disk.
This fixes a problem where outdated parent information breaks
the snapshot tree and hinders the deletion of child snapshots.
Reported by Philipp Hahn.
---
src/qemu/qemu_driver.c | 92 +++++++++++++++++++++++++++++++++++++-----------
1 files changed, 71 insertions(+), 21 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 924446f..9b538a3 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2607,10 +2607,10 @@ qemuPrepareMonitorChr(struct qemud_driver *driver,
return 0;
}
-static int qemuDomainSnapshotSetActive(virDomainObjPtr vm,
- char *snapshotDir);
-static int qemuDomainSnapshotSetInactive(virDomainObjPtr vm,
- char *snapshotDir);
+static int qemuDomainSnapshotSetCurrentActive(virDomainObjPtr vm,
+ char *snapshotDir);
+static int qemuDomainSnapshotSetCurrentInactive(virDomainObjPtr vm,
+ char *snapshotDir);
#define START_POSTFIX ": starting up\n"
@@ -2807,7 +2807,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
vm->current_snapshot, vmop)))
goto cleanup;
- if (qemuDomainSnapshotSetInactive(vm, driver->snapshotDir) < 0)
+ if (qemuDomainSnapshotSetCurrentInactive(vm, driver->snapshotDir) < 0)
goto cleanup;
/* now that we know it is about to start call the hook if present */
@@ -9472,8 +9472,9 @@ static char *qemuFindQemuImgBinary(void)
return ret;
}
-static int qemuDomainSnapshotWriteSnapshotMetadata(virDomainObjPtr vm,
- char *snapshotDir)
+static int qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
+ virDomainSnapshotObjPtr snapshot,
+ char *snapshotDir)
{
int fd = -1;
char *newxml = NULL;
@@ -9484,7 +9485,7 @@ static int qemuDomainSnapshotWriteSnapshotMetadata(virDomainObjPtr vm,
char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(vm->def->uuid, uuidstr);
- newxml = virDomainSnapshotDefFormat(uuidstr, vm->current_snapshot->def, 1);
+ newxml = virDomainSnapshotDefFormat(uuidstr, snapshot->def, 1);
if (newxml == NULL) {
virReportOOMError();
return -1;
@@ -9501,8 +9502,7 @@ static int qemuDomainSnapshotWriteSnapshotMetadata(virDomainObjPtr vm,
goto cleanup;
}
- if (virAsprintf(&snapFile, "%s/%s.xml", snapDir,
- vm->current_snapshot->def->name) < 0) {
+ if (virAsprintf(&snapFile, "%s/%s.xml", snapDir, snapshot->def->name) < 0) {
virReportOOMError();
goto cleanup;
}
@@ -9528,25 +9528,27 @@ cleanup:
return ret;
}
-static int qemuDomainSnapshotSetActive(virDomainObjPtr vm,
- char *snapshotDir)
+static int qemuDomainSnapshotSetCurrentActive(virDomainObjPtr vm,
+ char *snapshotDir)
{
if (vm->current_snapshot) {
vm->current_snapshot->def->active = 1;
- return qemuDomainSnapshotWriteSnapshotMetadata(vm, snapshotDir);
+ return qemuDomainSnapshotWriteMetadata(vm, vm->current_snapshot,
+ snapshotDir);
}
return 0;
}
-static int qemuDomainSnapshotSetInactive(virDomainObjPtr vm,
- char *snapshotDir)
+static int qemuDomainSnapshotSetCurrentInactive(virDomainObjPtr vm,
+ char *snapshotDir)
{
if (vm->current_snapshot) {
vm->current_snapshot->def->active = 0;
- return qemuDomainSnapshotWriteSnapshotMetadata(vm, snapshotDir);
+ return qemuDomainSnapshotWriteMetadata(vm, vm->current_snapshot,
+ snapshotDir);
}
return 0;
@@ -9686,8 +9688,9 @@ static virDomainSnapshotPtr qemuDomainSnapshotCreateXML(virDomainPtr domain,
/* Now we set the new current_snapshot for the domain */
vm->current_snapshot = snap;
- if (qemuDomainSnapshotWriteSnapshotMetadata(vm, driver->snapshotDir) < 0)
- /* qemuDomainSnapshotWriteSnapshotMetadata set the error */
+ if (qemuDomainSnapshotWriteMetadata(vm, vm->current_snapshot,
+ driver->snapshotDir) < 0)
+ /* qemuDomainSnapshotWriteMetadata set the error */
goto cleanup;
snapshot = virGetDomainSnapshot(domain, snap->def->name);
@@ -9941,13 +9944,13 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
goto endjob;
}
else {
- if (qemuDomainSnapshotSetActive(vm, driver->snapshotDir) < 0)
+ if (qemuDomainSnapshotSetCurrentActive(vm, driver->snapshotDir) < 0)
goto endjob;
rc = qemudStartVMDaemon(snapshot->domain->conn, driver, vm, NULL,
false, -1, NULL, VIR_VM_OP_CREATE);
qemuDomainStartAudit(vm, "from-snapshot", rc >= 0);
- if (qemuDomainSnapshotSetInactive(vm, driver->snapshotDir) < 0)
+ if (qemuDomainSnapshotSetCurrentInactive(vm, driver->snapshotDir) < 0)
goto endjob;
if (rc < 0)
goto endjob;
@@ -9991,7 +9994,7 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
}
}
- if (qemuDomainSnapshotSetActive(vm, driver->snapshotDir) < 0)
+ if (qemuDomainSnapshotSetCurrentActive(vm, driver->snapshotDir) < 0)
goto endjob;
}
@@ -10128,6 +10131,43 @@ static void qemuDomainSnapshotDiscardChildren(void *payload,
}
}
+struct snap_reparent {
+ struct qemud_driver *driver;
+ virDomainSnapshotObjPtr snap;
+ virDomainObjPtr vm;
+ int err;
+};
+
+static void
+qemuDomainSnapshotReparentChildren(void *payload,
+ const char *name ATTRIBUTE_UNUSED,
+ void *data)
+{
+ virDomainSnapshotObjPtr snap = payload;
+ struct snap_reparent *rep = data;
+
+ if (rep->err < 0) {
+ return;
+ }
+
+ if (snap->def->parent && STREQ(snap->def->parent, rep->snap->def->name)) {
+ VIR_FREE(snap->def->parent);
+
+ if (rep->snap->def->parent != NULL) {
+ snap->def->parent = strdup(rep->snap->def->parent);
+
+ if (snap->def->parent == NULL) {
+ virReportOOMError();
+ rep->err = -1;
+ return;
+ }
+ }
+
+ rep->err = qemuDomainSnapshotWriteMetadata(rep->vm, snap,
+ rep->driver->snapshotDir);
+ }
+}
+
static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
unsigned int flags)
{
@@ -10137,6 +10177,7 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
virDomainSnapshotObjPtr snap = NULL;
char uuidstr[VIR_UUID_STRING_BUFLEN];
struct snap_remove rem;
+ struct snap_reparent rep;
virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN, -1);
@@ -10169,6 +10210,15 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
&rem);
if (rem.err < 0)
goto endjob;
+ } else {
+ rep.driver = driver;
+ rep.snap = snap;
+ rep.vm = vm;
+ rep.err = 0;
+ virHashForEach(vm->snapshots.objs, qemuDomainSnapshotReparentChildren,
+ &rep);
+ if (rep.err < 0)
+ goto endjob;
}
ret = qemuDomainSnapshotDiscard(driver, vm, snap);
--
1.7.0.4
3
4
23 Dec '10
* Changes since v4:
Fix a bug and a memory leak in vmwareParsePath()
Remove domainSave/Restore functions because more work is needed on them
4
11
---
tools/virsh.c | 5 +++++
tools/virsh.pod | 14 ++++++++------
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 4e37f2d..774d937 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -8293,6 +8293,7 @@ static const vshCmdOptDef opts_update_device[] = {
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
{"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("XML file")},
{"persistent", VSH_OT_BOOL, 0, N_("persist device update")},
+ {"force", VSH_OT_BOOL, 0, N_("force device update")},
{NULL, 0, 0, NULL}
};
@@ -8331,6 +8332,10 @@ cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd)
} else {
flags = VIR_DOMAIN_DEVICE_MODIFY_LIVE;
}
+
+ if (vshCommandOptBool(cmd, "force"))
+ flags |= VIR_DOMAIN_DEVICE_MODIFY_FORCE;
+
ret = virDomainUpdateDeviceFlags(dom, buffer, flags);
VIR_FREE(buffer);
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 9cb6829..9c45a61 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -731,12 +731,14 @@ I<type> can be either I<network> to indicate a physical network device or I<brid
It is recommended to use the I<mac> option to distinguish between the interfaces
if more than one are present on the domain.
-=item B<update-device> I<domain-id> I<file> optional I<--persistent>
-
-Update the characteristics of a device associated with I<domain-id>,
-based on the device definition in an XML I<file>. If the I<--persistent>
-option is used, the changes will affect the next boot of the domain.
-See the documentation to learn about libvirt XML format for a device.
+=item B<update-device> I<domain-id> I<file> optional I<--persistent> I<--force>
+
+Update the characteristics of a device associated with I<domain-id>, based on
+the device definition in an XML I<file>. If the I<--persistent> option is
+used, the changes will affect the next boot of the domain. The I<--force>
+option can be used to force device update, e.g., to eject a CD-ROM even if it
+is locked/mounted in the domain. See the documentation to learn about libvirt
+XML format for a device.
=back
--
1.7.3.4
2
2
23 Dec '10
when we use an external process to connect remote libvirtd,
virsh will coredump:
# virsh -c qemu+ext://<target_ip>/system?command=cmd
Segmentation fault (core dumped)
This bug was caused by 3348a97b.
Signed-off-by: Wen Congyang <wency(a)cn.fujitsu.com>
---
src/remote/remote_driver.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index fae191c..1c13f4a 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -802,6 +802,18 @@ doRemoteOpen (virConnectPtr conn,
goto failed;
}
+ /* Run the external process. */
+ if (!cmd_argv) {
+ if (VIR_ALLOC_N(cmd_argv, 2) < 0)
+ goto out_of_memory;
+
+ cmd_argv[0] = strdup(command);
+ if (cmd_argv[0] == NULL)
+ goto out_of_memory;
+
+ cmd_argv[1] = NULL;
+ }
+
if (virExec((const char**)cmd_argv, NULL, NULL,
&pid, sv[1], &(sv[1]), &(errfd[1]),
VIR_EXEC_CLEAR_CAPS) < 0)
--
1.7.1
2
3
---
tools/virsh.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 4e37f2d..8c123bb 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -10935,8 +10935,10 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser)
if (tk == VSH_TK_ERROR)
goto syntaxError;
- if (tk != VSH_TK_ARG)
+ if (tk != VSH_TK_ARG) {
+ VIR_FREE(tkdata);
break;
+ }
if (cmd == NULL) {
/* first token must be command name */
--
1.7.3.1
--
Thanks,
Hu Tao
2
2
Hello,
I encountered another problem: snapshots are linked to there parent snapshot.
If the parent snapshot is deleted, the chain gets broken and deleting the
child snapshot terminates with an error message:
> error: Domain snapshot not found: no domain snapshot parent with matching
name '1291813671'
I can reproduce this using the following sequence of commands for my
test-domain called "test" using a singel qcow2 image:
# virsh snapshot-create test # 1291813670
# virsh snapshot-create test # 1291813671
# virsh snapshot-create test # 1291813672
# virsh snapshot-delete test 1291813671
# virsh snapshot-delete test 1291813672
Is this problem known (libvirt-0.8.3)?
Reverting to such an unlinked snapshot is still possible, but deleting it is
not.
Sincerely
Philipp Hahn
--
Philipp Hahn Open Source Software Engineer hahn(a)univention.de
Univention GmbH Linux for Your Business fon: +49 421 22 232- 0
Mary-Somerville-Str.1 28359 Bremen fax: +49 421 22 232-99
http://www.univention.de
2
1
I began noticing a race when reserving VNC ports as described here
https://www.redhat.com/archives/libvir-list/2010-November/msg00379.html
Turns out that we were not initializing the size field of bitmap
struct when allocating the bitmap. This subsequently caused
virBitmapSetBit() to fail since bitmap->size is 0, hence we never
actually reserved the port.
---
src/util/bitmap.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/util/bitmap.c b/src/util/bitmap.c
index 1b0c9da..9741668 100644
--- a/src/util/bitmap.c
+++ b/src/util/bitmap.c
@@ -73,6 +73,7 @@ virBitmapPtr virBitmapAlloc(size_t size)
return NULL;
}
+ bitmap->size = size;
return bitmap;
}
--
1.7.3.1
2
2
22 Dec '10
---
src/esx/esx_storage_driver.c | 50 +++++++++++++++++++++++++++++++++++++++-
src/esx/esx_vi_generator.input | 7 +++++
2 files changed, 56 insertions(+), 1 deletions(-)
diff --git a/src/esx/esx_storage_driver.c b/src/esx/esx_storage_driver.c
index e6803c2..544551c 100644
--- a/src/esx/esx_storage_driver.c
+++ b/src/esx/esx_storage_driver.c
@@ -1377,6 +1377,54 @@ esxStorageVolumeCreateXMLFrom(virStoragePoolPtr pool, const char *xmldesc,
static int
+esxStorageVolumeDelete(virStorageVolPtr volume, unsigned int flags)
+{
+ int result = -1;
+ esxPrivate *priv = volume->conn->storagePrivateData;
+ char *datastorePath = NULL;
+ esxVI_ManagedObjectReference *task = NULL;
+ esxVI_TaskInfoState taskInfoState;
+ char *taskInfoErrorMessage = NULL;
+
+ virCheckFlags(0, -1);
+
+ if (esxVI_EnsureSession(priv->primary) < 0) {
+ return -1;
+ }
+
+ if (virAsprintf(&datastorePath, "[%s] %s", volume->pool, volume->name) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ if (esxVI_DeleteVirtualDisk_Task(priv->primary, datastorePath,
+ priv->primary->datacenter->_reference,
+ &task) < 0 ||
+ esxVI_WaitForTaskCompletion(priv->primary, task, NULL,
+ esxVI_Occurrence_None, priv->autoAnswer,
+ &taskInfoState, &taskInfoErrorMessage) < 0) {
+ goto cleanup;
+ }
+
+ if (taskInfoState != esxVI_TaskInfoState_Success) {
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR, _("Could not delete volume: %s"),
+ taskInfoErrorMessage);
+ goto cleanup;
+ }
+
+ result = 0;
+
+ cleanup:
+ VIR_FREE(datastorePath);
+ esxVI_ManagedObjectReference_Free(&task);
+ VIR_FREE(taskInfoErrorMessage);
+
+ return result;
+}
+
+
+
+static int
esxStorageVolumeGetInfo(virStorageVolPtr volume, virStorageVolInfoPtr info)
{
int result = -1;
@@ -1574,7 +1622,7 @@ static virStorageDriver esxStorageDriver = {
esxStorageVolumeLookupByPath, /* volLookupByPath */
esxStorageVolumeCreateXML, /* volCreateXML */
esxStorageVolumeCreateXMLFrom, /* volCreateXMLFrom */
- NULL, /* volDelete */
+ esxStorageVolumeDelete, /* volDelete */
NULL, /* volWipe */
esxStorageVolumeGetInfo, /* volGetInfo */
esxStorageVolumeDumpXML, /* volGetXMLDesc */
diff --git a/src/esx/esx_vi_generator.input b/src/esx/esx_vi_generator.input
index 4018c6e..bd2da11 100644
--- a/src/esx/esx_vi_generator.input
+++ b/src/esx/esx_vi_generator.input
@@ -735,6 +735,13 @@ method CreateVirtualDisk_Task returns ManagedObjectReference r
end
+method DeleteVirtualDisk_Task returns ManagedObjectReference r
+ ManagedObjectReference _this:VirtualDiskManager r
+ String name r
+ ManagedObjectReference datacenter o
+end
+
+
method DestroyPropertyFilter
ManagedObjectReference _this r
end
--
1.7.0.4
2
2
22 Dec '10
---
src/esx/esx_storage_driver.c | 50 +++++++++++++++++++++++++++++++++++++++-
src/esx/esx_vi_generator.input | 7 +++++
2 files changed, 56 insertions(+), 1 deletions(-)
diff --git a/src/esx/esx_storage_driver.c b/src/esx/esx_storage_driver.c
index 544551c..12c8f5e 100644
--- a/src/esx/esx_storage_driver.c
+++ b/src/esx/esx_storage_driver.c
@@ -1425,6 +1425,54 @@ esxStorageVolumeDelete(virStorageVolPtr volume, unsigned int flags)
static int
+esxStorageVolumeWipe(virStorageVolPtr volume, unsigned int flags)
+{
+ int result = -1;
+ esxPrivate *priv = volume->conn->storagePrivateData;
+ char *datastorePath = NULL;
+ esxVI_ManagedObjectReference *task = NULL;
+ esxVI_TaskInfoState taskInfoState;
+ char *taskInfoErrorMessage = NULL;
+
+ virCheckFlags(0, -1);
+
+ if (esxVI_EnsureSession(priv->primary) < 0) {
+ return -1;
+ }
+
+ if (virAsprintf(&datastorePath, "[%s] %s", volume->pool, volume->name) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ if (esxVI_ZeroFillVirtualDisk_Task(priv->primary, datastorePath,
+ priv->primary->datacenter->_reference,
+ &task) < 0 ||
+ esxVI_WaitForTaskCompletion(priv->primary, task, NULL,
+ esxVI_Occurrence_None, priv->autoAnswer,
+ &taskInfoState, &taskInfoErrorMessage) < 0) {
+ goto cleanup;
+ }
+
+ if (taskInfoState != esxVI_TaskInfoState_Success) {
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR, _("Could not wipe volume: %s"),
+ taskInfoErrorMessage);
+ goto cleanup;
+ }
+
+ result = 0;
+
+ cleanup:
+ VIR_FREE(datastorePath);
+ esxVI_ManagedObjectReference_Free(&task);
+ VIR_FREE(taskInfoErrorMessage);
+
+ return result;
+}
+
+
+
+static int
esxStorageVolumeGetInfo(virStorageVolPtr volume, virStorageVolInfoPtr info)
{
int result = -1;
@@ -1623,7 +1671,7 @@ static virStorageDriver esxStorageDriver = {
esxStorageVolumeCreateXML, /* volCreateXML */
esxStorageVolumeCreateXMLFrom, /* volCreateXMLFrom */
esxStorageVolumeDelete, /* volDelete */
- NULL, /* volWipe */
+ esxStorageVolumeWipe, /* volWipe */
esxStorageVolumeGetInfo, /* volGetInfo */
esxStorageVolumeDumpXML, /* volGetXMLDesc */
esxStorageVolumeGetPath, /* volGetPath */
diff --git a/src/esx/esx_vi_generator.input b/src/esx/esx_vi_generator.input
index bd2da11..2d903e4 100644
--- a/src/esx/esx_vi_generator.input
+++ b/src/esx/esx_vi_generator.input
@@ -916,3 +916,10 @@ method WaitForUpdates returns UpdateSet r
ManagedObjectReference _this:PropertyCollector r
String version o
end
+
+
+method ZeroFillVirtualDisk_Task returns ManagedObjectReference r
+ ManagedObjectReference _this:VirtualDiskManager r
+ String name r
+ ManagedObjectReference datacenter o
+end
--
1.7.0.4
2
2
22 Dec '10
Commit ed0d9f6c0cdd56f38ce31b8d9b5293162addaa23 added support for
automatic port allocation for SPICE but forgot to mark such ports as
unused when they are not used anymore.
---
src/qemu/qemu_driver.c | 30 ++++++++++++++++++++++--------
1 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1a26a50..1de6f4a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2491,6 +2491,19 @@ static int qemudNextFreePort(struct qemud_driver *driver,
}
+static void
+qemudReturnPort(struct qemud_driver *driver,
+ int port)
+{
+ if (port < QEMU_VNC_PORT_MIN)
+ return;
+
+ if (virBitmapClearBit(driver->reservedVNCPorts,
+ port - QEMU_VNC_PORT_MIN) < 0)
+ VIR_DEBUG("Could not mark port %d as unused", port);
+}
+
+
static int
qemuAssignPCIAddresses(virDomainDefPtr def)
{
@@ -2696,6 +2709,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
if (tlsPort < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Unable to find an unused SPICE TLS port"));
+ qemudReturnPort(driver, port);
goto cleanup;
}
}
@@ -3099,14 +3113,14 @@ retry:
*/
if ((vm->def->ngraphics == 1) &&
vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
- vm->def->graphics[0]->data.vnc.autoport &&
- vm->def->graphics[0]->data.vnc.port >= QEMU_VNC_PORT_MIN) {
- if (virBitmapClearBit(driver->reservedVNCPorts,
- vm->def->graphics[0]->data.vnc.port - \
- QEMU_VNC_PORT_MIN) < 0) {
- VIR_DEBUG("virBitmapClearBit failed on bit %d",
- vm->def->graphics[0]->data.vnc.port - QEMU_VNC_PORT_MIN);
- }
+ vm->def->graphics[0]->data.vnc.autoport) {
+ qemudReturnPort(driver, vm->def->graphics[0]->data.vnc.port);
+ }
+ if ((vm->def->ngraphics == 1) &&
+ vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE &&
+ vm->def->graphics[0]->data.spice.autoport) {
+ qemudReturnPort(driver, vm->def->graphics[0]->data.spice.port);
+ qemudReturnPort(driver, vm->def->graphics[0]->data.spice.tlsPort);
}
vm->pid = -1;
--
1.7.3.4
3
4
All,
I'll preface this by saying that I'm not 100% sure I'm correct. But I
still think there may be an API break that was introduced with the VMware
player driver. In include/libvirt/virterror.h, VIR_FROM_VMWARE was added to
the *middle* of the enum for virErrorDomain. If any clients of libvirt happen
to be using hardcoded numbers, then they will now have the wrong number for
everything after VIR_FROM_VMWARE.
Looking back through the history of virErrorDomain, it doesn't seem like this
is the first time this has happened. What's the thinking with virErrorDomain?
Part of the API, or up to the clients to properly use the named enums?
--
Chris Lalancette
4
6
Hi folks,
Is there a global "boot time delay" configuration parameter
to make sure that the autostart domains are not started all
in parallel at boot time?
Any helpful comment would be highly appreciated.
Harri
4
3
I thought I'd take a look at updating my libvirt stack on EL5.5. Building the
Fedora Rawhide 0.8.5 rpm in mock yields:
make check-TESTS
make[2]: Entering directory `/builddir/build/BUILD/libvirt-0.8.5/tests'
TEST: virshtest
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 40
!!!!!!! 47 FAIL
FAIL: virshtest
...
TEST: interfaceschematest
!!..!.!.....!..... 18 FAILED
FAIL: interfaceschematest
Expected? Cause for concern?
--
Orion Poplawski
Technical Manager 303-415-9701 x222
NWRA/CoRA Division FAX: 303-415-9702
3380 Mitchell Lane orion(a)cora.nwra.com
Boulder, CO 80301 http://www.cora.nwra.com
3
2
---
docs/drvopenvz.html.in | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/docs/drvopenvz.html.in b/docs/drvopenvz.html.in
index e446b1a..485d209 100644
--- a/docs/drvopenvz.html.in
+++ b/docs/drvopenvz.html.in
@@ -2,6 +2,8 @@
<body>
<h1>OpenVZ container driver</h1>
+ <ul id="toc"></ul>
+
<p>
The OpenVZ driver for libvirt allows use and management of container
based virtualization on a Linux host OS. Prior to using the OpenVZ
@@ -11,11 +13,11 @@
undue trouble.
</p>
- <h2>Connections to OpenVZ driver</h2>
+ <h2><a name="connections">Connections to OpenVZ driver</a></h2>
<p>
The libvirt OpenVZ driver is a single-instance privileged driver,
- with a driver name of 'openvz'. Some example conection URIs for
+ with a driver name of 'openvz'. Some example connection URIs for
the libvirt driver are:
</p>
@@ -27,7 +29,7 @@ openvz+tcp://example.com/system (remote access, SASl/Kerberos)
openvz+ssh://root@example.com/system (remote access, SSH tunnelled)
</pre>
- <h2>Notes on bridged networking</h2>
+ <h2><a name="notes">Notes on bridged networking</a></h2>
<p>
Bridged networking enables a guest domain (ie container) to have its
@@ -36,7 +38,7 @@ openvz+ssh://root@example.com/system (remote access, SSH tunnelled)
the host OS.
</p>
- <h3>Host network devices</h3>
+ <h3><a name="host">Host network devices</a></h3>
<p>
One or more of the physical devices must be attached to a bridge. The
@@ -47,7 +49,7 @@ openvz+ssh://root@example.com/system (remote access, SSH tunnelled)
physical device "eth0", or a bonding device "bond0".
</p>
- <h3>OpenVZ tools configuration</h3>
+ <h3><a name="tools">OpenVZ tools configuration</a></h3>
<p>
OpenVZ releases later than 3.0.23 ship with a standard network device
@@ -72,7 +74,7 @@ EXTERNAL_SCRIPT="/usr/sbin/vznetaddbr"
</p>
- <h2>Example guest domain XML configuration</h2>
+ <h2><a name="example">Example guest domain XML configuration</a></h2>
<p>
The current libvirt OpenVZ driver has a restriction that the
--
1.7.3.2
1
1
22 Dec '10
If there is a dangling symbol link in filesystem pool, the pool
will be failed to start or refresh, this patch is to fix it by
ignoring it with a warning log.
* src/storage/storage_backend.c
* src/storage/storage_backend_fs.c (update the comments)
---
src/storage/storage_backend.c | 9 ++++++++-
src/storage/storage_backend_fs.c | 2 +-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 10ea33c..9504261 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -977,7 +977,8 @@ virStorageBackendForType(int type) {
/*
* Allows caller to silently ignore files with improper mode
*
- * Returns -1 on error, -2 if file mode is unexpected.
+ * Returns -1 on error, -2 if file mode is unexpected or the file
+ * is symbol link, and it's dangling.
*/
int
virStorageBackendVolOpenCheckMode(const char *path, unsigned int flags)
@@ -986,6 +987,12 @@ virStorageBackendVolOpenCheckMode(const char *path, unsigned int flags)
struct stat sb;
if ((fd = open(path, O_RDONLY|O_NONBLOCK|O_NOCTTY)) < 0) {
+ if (areadlink(path) != NULL) {
+ VIR_WARN("cannot open volume '%s': %s", path,
+ strerror(errno));
+ return -2;
+ }
+
virReportSystemError(errno,
_("cannot open volume '%s'"),
path);
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index d916d2d..242508c 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -651,7 +651,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED,
goto cleanup;
else {
/* Silently ignore non-regular files,
- * eg '.' '..', 'lost+found' */
+ * eg '.' '..', 'lost+found', dangling symbol link */
virStorageVolDefFree(vol);
vol = NULL;
continue;
--
1.7.3.2
2
5
This fixes the build from a tarball and makes autobuild.sh
work again.
This should actually have been part of this earlier commit:
esx: Move VMX handling code out of the driver directory
42b2f35d36a9e33f03e973130267c19cff910f2e
Reported by Eric Blake.
---
I pushed this under the (auto)build breaker rule :)
Matthias
src/Makefile.am | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 7ecd3e0..41d4b34 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1066,7 +1066,8 @@ EXTRA_DIST += \
libvirt_linux.syms \
libvirt_macvtap.syms \
libvirt_daemon.syms \
- libvirt_nwfilter.syms
+ libvirt_nwfilter.syms \
+ libvirt_vmx.syms
BUILT_SOURCES += libvirt.syms libvirt.def libvirt_qemu.def
--
1.7.0.4
1
0
[libvirt] [PATCH] bridge_driver: cleanup improvements in dhcpStartDhcpDaemon()
by Paweł Krześniak 22 Dec '10
by Paweł Krześniak 22 Dec '10
22 Dec '10
Run VIR_FREE only for non-NULL pointers.
---
src/network/bridge_driver.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index b0834ae..f2857b4 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -534,34 +534,34 @@ dhcpStartDhcpDaemon(virNetworkObjPtr network)
if (!VIR_SOCKET_IS_FAMILY(&network->def->ipAddress, AF_INET)) {
networkReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot start dhcp daemon without
IPv4 address for server"));
- goto cleanup;
+ goto cleanup2;
}
if ((err = virFileMakePath(NETWORK_PID_DIR)) != 0) {
virReportSystemError(err,
_("cannot create directory %s"),
NETWORK_PID_DIR);
- goto cleanup;
+ goto cleanup2;
}
if ((err = virFileMakePath(NETWORK_STATE_DIR)) != 0) {
virReportSystemError(err,
_("cannot create directory %s"),
NETWORK_STATE_DIR);
- goto cleanup;
+ goto cleanup2;
}
if (!(pidfile = virFilePid(NETWORK_PID_DIR, network->def->name))) {
virReportOOMError();
- goto cleanup;
+ goto cleanup2;
}
cmd = virCommandNew(DNSMASQ);
if (networkBuildDnsmasqArgv(network, pidfile, cmd) < 0) {
- goto cleanup;
+ goto cleanup1;
}
if (virCommandRun(cmd, NULL) < 0)
- goto cleanup;
+ goto cleanup1;
/*
* There really is no race here - when dnsmasq daemonizes, its
@@ -573,12 +573,13 @@ dhcpStartDhcpDaemon(virNetworkObjPtr network)
if (virFileReadPid(NETWORK_PID_DIR, network->def->name,
&network->dnsmasqPid) < 0)
- goto cleanup;
+ goto cleanup1;
ret = 0;
-cleanup:
+cleanup1:
VIR_FREE(pidfile);
virCommandFree(cmd);
+cleanup2:
return ret;
}
2
1
[libvirt] [PATCH] vmware: Fix undefine symbol with loadable drivers enabled
by Matthias Bolte 21 Dec '10
by Matthias Bolte 21 Dec '10
21 Dec '10
All other drivers are explicitly linked to gnulib. The VMware
driver lacked this, resulting in mdir_name being an undefine
symbol.
Explicitly link the VMware driver to gnulib to fix this.
---
src/Makefile.am | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 607e391..7ecd3e0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -633,6 +633,7 @@ endif
libvirt_driver_vmware_la_CFLAGS = \
-I@top_srcdir@/src/conf -I@top_srcdir@/src/vmx
if WITH_DRIVER_MODULES
+libvirt_driver_vmware_la_LIBADD = ../gnulib/lib/libgnu.la
libvirt_driver_vmware_la_LDFLAGS = -module -avoid-version
endif
libvirt_driver_vmware_la_SOURCES = $(VMWARE_DRIVER_SOURCES)
--
1.7.0.4
2
2
[libvirt] [PATCH] esx: Move VMX handling code out of the driver directory
by Matthias Bolte 21 Dec '10
by Matthias Bolte 21 Dec '10
21 Dec '10
Now the VMware driver doesn't depend on the ESX driver anymore.
Add a WITH_VMX option that depends on WITH_ESX and WITH_VMWARE.
Also add a libvirt_vmx.syms file.
Move some escaping functions from esx_util.c to vmx.c.
Adapt the test suite, ESX and VMware driver to the new code layout.
---
configure.ac | 9 +
po/POTFILES.in | 2 +-
src/Makefile.am | 22 +-
src/esx/esx_driver.c | 48 +-
src/esx/esx_util.c | 309 +------------
src/esx/esx_util.h | 27 -
src/esx/esx_vi.c | 40 ++-
src/esx/esx_vi.h | 2 +
src/esx/esx_vmx.h | 154 ------
src/libvirt_vmx.syms | 23 +
src/vmware/vmware_conf.c | 13 +-
src/vmware/vmware_conf.h | 2 +-
src/vmware/vmware_driver.c | 22 +-
src/{esx/esx_vmx.c => vmx/vmx.c} | 1019 +++++++++++++++++++++++--------------
src/vmx/vmx.h | 132 +++++
tests/Makefile.am | 22 +-
tests/esxutilstest.c | 5 +-
tests/vmx2xmltest.c | 108 ++--
tests/xml2vmxtest.c | 120 +++--
19 files changed, 1044 insertions(+), 1035 deletions(-)
delete mode 100644 src/esx/esx_vmx.h
create mode 100644 src/libvirt_vmx.syms
rename src/{esx/esx_vmx.c => vmx/vmx.c} (79%)
create mode 100644 src/vmx/vmx.h
diff --git a/configure.ac b/configure.ac
index 4df915a..87fd967 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1759,6 +1759,15 @@ if test "$with_esx" = "yes" ; then
fi
AM_CONDITIONAL([WITH_ESX], [test "$with_esx" = "yes"])
+with_vmx=yes
+if test "$with_esx" != "yes" && test "$with_vmware" != "yes"; then
+ with_vmx=no
+fi
+if test "$with_vmx" = "yes" ; then
+ AC_DEFINE_UNQUOTED([WITH_VMX], 1, [whether VMware VMX config handling is enabled])
+fi
+AM_CONDITIONAL([WITH_VMX], [test "$with_vmx" = "yes"])
+
if test "$with_xenapi" = "yes" ; then
AC_DEFINE_UNQUOTED([WITH_XENAPI], 1, [whether XenAPI driver is enabled])
fi
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 3b851f1..3d7bc8b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -25,7 +25,6 @@ src/esx/esx_util.c
src/esx/esx_vi.c
src/esx/esx_vi_methods.c
src/esx/esx_vi_types.c
-src/esx/esx_vmx.c
src/fdstream.c
src/interface/netcf_driver.c
src/internal.h
@@ -109,6 +108,7 @@ src/vbox/vbox_driver.c
src/vbox/vbox_tmpl.c
src/vmware/vmware_conf.c
src/vmware/vmware_driver.c
+src/vmx/vmx.c
src/xen/xen_driver.c
src/xen/xen_hypervisor.c
src/xen/xen_inotify.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 07ec528..588a4f7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -322,8 +322,7 @@ ESX_DRIVER_SOURCES = \
esx/esx_util.c esx/esx_util.h \
esx/esx_vi.c esx/esx_vi.h \
esx/esx_vi_methods.c esx/esx_vi_methods.h \
- esx/esx_vi_types.c esx/esx_vi_types.h \
- esx/esx_vmx.c esx/esx_vmx.h
+ esx/esx_vi_types.c esx/esx_vi_types.h
ESX_DRIVER_GENERATED = \
esx/esx_vi_methods.generated.c \
@@ -418,6 +417,9 @@ CPU_SOURCES = \
cpu/cpu_x86.h cpu/cpu_x86.c cpu/cpu_x86_data.h \
cpu/cpu_map.h cpu/cpu_map.c
+VMX_SOURCES = \
+ vmx/vmx.c vmx/vmx.h
+
pkgdata_DATA = cpu/cpu_map.xml
EXTRA_DIST += $(pkgdata_DATA)
@@ -451,6 +453,14 @@ libvirt_cpu_la_CFLAGS = \
-I@top_srcdir@/src/conf $(AM_CFLAGS)
libvirt_cpu_la_SOURCES = $(CPU_SOURCES)
+if WITH_VMX
+noinst_LTLIBRARIES += libvirt_vmx.la
+libvirt_la_BUILT_LIBADD += libvirt_vmx.la
+libvirt_vmx_la_CFLAGS = \
+ -I@top_srcdir@/src/conf $(AM_CFLAGS)
+libvirt_vmx_la_SOURCES = $(VMX_SOURCES)
+endif
+
noinst_LTLIBRARIES += libvirt_driver.la
libvirt_la_BUILT_LIBADD += libvirt_driver.la
@@ -621,7 +631,7 @@ noinst_LTLIBRARIES += libvirt_driver_vmware.la
libvirt_la_BUILT_LIBADD += libvirt_driver_vmware.la
endif
libvirt_driver_vmware_la_CFLAGS = \
- -I@top_srcdir@/src/conf
+ -I@top_srcdir@/src/conf -I@top_srcdir@/src/vmx
if WITH_DRIVER_MODULES
libvirt_driver_vmware_la_LDFLAGS = -module -avoid-version
endif
@@ -768,7 +778,7 @@ noinst_LTLIBRARIES += libvirt_driver_esx.la
libvirt_la_BUILT_LIBADD += libvirt_driver_esx.la
endif
libvirt_driver_esx_la_CFLAGS = $(LIBCURL_CFLAGS) \
- -I@top_srcdir@/src/conf $(AM_CFLAGS)
+ -I@top_srcdir@/src/conf -I@top_srcdir@/src/vmx $(AM_CFLAGS)
libvirt_driver_esx_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_esx_la_LIBADD = $(LIBCURL_LIBS)
if WITH_DRIVER_MODULES
@@ -1043,6 +1053,10 @@ if WITH_NWFILTER
USED_SYM_FILES += libvirt_nwfilter.syms
endif
+if WITH_VMX
+USED_SYM_FILES += libvirt_vmx.syms
+endif
+
EXTRA_DIST += \
libvirt_public.syms \
libvirt_private.syms \
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 03a7be3..cc9b119 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -31,6 +31,7 @@
#include "memory.h"
#include "logging.h"
#include "uuid.h"
+#include "vmx.h"
#include "esx_driver.h"
#include "esx_interface_driver.h"
#include "esx_network_driver.h"
@@ -42,7 +43,6 @@
#include "esx_vi.h"
#include "esx_vi_methods.h"
#include "esx_util.h"
-#include "esx_vmx.h"
#define VIR_FROM_THIS VIR_FROM_ESX
@@ -88,7 +88,7 @@ struct _esxVMX_Data {
* Firstly this functions checks if the given file name contains a separator.
* If it doesn't then the referenced file is in the same directory as the .vmx
* file. The datastore name and directory of the .vmx file are passed to this
- * function via the opaque paramater by the caller of esxVMX_ParseConfig.
+ * function via the opaque paramater by the caller of virVMXParseConfig.
*
* Otherwise query for all known datastores and their mount directories. Then
* try to find a datastore with a mount directory that is a prefix to the given
@@ -584,10 +584,6 @@ esxCapsInit(esxPrivate *priv)
goto failure;
}
- /*
- * FIXME: Maybe distinguish betwen ESX and GSX here, see
- * esxVMX_ParseConfig() and VIR_DOMAIN_VIRT_VMWARE
- */
if (virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0,
NULL) == NULL) {
goto failure;
@@ -602,10 +598,6 @@ esxCapsInit(esxPrivate *priv)
goto failure;
}
- /*
- * FIXME: Maybe distinguish betwen ESX and GSX here, see
- * esxVMX_ParseConfig() and VIR_DOMAIN_VIRT_VMWARE
- */
if (virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0,
NULL) == NULL) {
goto failure;
@@ -2570,7 +2562,7 @@ esxDomainDumpXML(virDomainPtr domain, int flags)
virBuffer buffer = VIR_BUFFER_INITIALIZER;
char *url = NULL;
char *vmx = NULL;
- esxVMX_Context ctx;
+ virVMXContext ctx;
esxVMX_Data data;
virDomainDefPtr def = NULL;
char *xml = NULL;
@@ -2637,8 +2629,7 @@ esxDomainDumpXML(virDomainPtr domain, int flags)
ctx.formatFileName = NULL;
ctx.autodetectSCSIControllerModel = NULL;
- def = esxVMX_ParseConfig(&ctx, priv->caps, vmx,
- priv->primary->productVersion);
+ def = virVMXParseConfig(&ctx, priv->caps, vmx);
if (def != NULL) {
if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) {
@@ -2674,7 +2665,7 @@ esxDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
unsigned int flags ATTRIBUTE_UNUSED)
{
esxPrivate *priv = conn->privateData;
- esxVMX_Context ctx;
+ virVMXContext ctx;
esxVMX_Data data;
virDomainDefPtr def = NULL;
char *xml = NULL;
@@ -2693,8 +2684,7 @@ esxDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
ctx.formatFileName = NULL;
ctx.autodetectSCSIControllerModel = NULL;
- def = esxVMX_ParseConfig(&ctx, priv->caps, nativeConfig,
- priv->primary->productVersion);
+ def = virVMXParseConfig(&ctx, priv->caps, nativeConfig);
if (def != NULL) {
xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE);
@@ -2713,7 +2703,8 @@ esxDomainXMLToNative(virConnectPtr conn, const char *nativeFormat,
unsigned int flags ATTRIBUTE_UNUSED)
{
esxPrivate *priv = conn->privateData;
- esxVMX_Context ctx;
+ int virtualHW_version;
+ virVMXContext ctx;
esxVMX_Data data;
virDomainDefPtr def = NULL;
char *vmx = NULL;
@@ -2724,6 +2715,13 @@ esxDomainXMLToNative(virConnectPtr conn, const char *nativeFormat,
return NULL;
}
+ virtualHW_version = esxVI_ProductVersionToDefaultVirtualHWVersion
+ (priv->primary->productVersion);
+
+ if (virtualHW_version < 0) {
+ return NULL;
+ }
+
def = virDomainDefParseString(priv->caps, domainXml, 0);
if (def == NULL) {
@@ -2738,8 +2736,7 @@ esxDomainXMLToNative(virConnectPtr conn, const char *nativeFormat,
ctx.formatFileName = esxFormatVMXFileName;
ctx.autodetectSCSIControllerModel = esxAutodetectSCSIControllerModel;
- vmx = esxVMX_FormatConfig(&ctx, priv->caps, def,
- priv->primary->productVersion);
+ vmx = virVMXFormatConfig(&ctx, priv->caps, def, virtualHW_version);
virDomainDefFree(def);
@@ -2922,7 +2919,8 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml)
int i;
virDomainDiskDefPtr disk = NULL;
esxVI_ObjectContent *virtualMachine = NULL;
- esxVMX_Context ctx;
+ int virtualHW_version;
+ virVMXContext ctx;
esxVMX_Data data;
char *datastoreName = NULL;
char *directoryName = NULL;
@@ -2973,6 +2971,13 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml)
}
/* Build VMX from domain XML */
+ virtualHW_version = esxVI_ProductVersionToDefaultVirtualHWVersion
+ (priv->primary->productVersion);
+
+ if (virtualHW_version < 0) {
+ goto cleanup;
+ }
+
data.ctx = priv->primary;
data.datastorePathWithoutFileName = NULL;
@@ -2981,8 +2986,7 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml)
ctx.formatFileName = esxFormatVMXFileName;
ctx.autodetectSCSIControllerModel = esxAutodetectSCSIControllerModel;
- vmx = esxVMX_FormatConfig(&ctx, priv->caps, def,
- priv->primary->productVersion);
+ vmx = virVMXFormatConfig(&ctx, priv->caps, def, virtualHW_version);
if (vmx == NULL) {
goto cleanup;
diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index 9ab0f70..2603957 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -24,7 +24,6 @@
#include <config.h>
-#include <c-ctype.h>
#include <netdb.h>
#include "internal.h"
@@ -34,6 +33,7 @@
#include "memory.h"
#include "logging.h"
#include "uuid.h"
+#include "vmx.h"
#include "esx_private.h"
#include "esx_util.h"
@@ -415,198 +415,6 @@ esxUtil_ResolveHostname(const char *hostname,
int
-esxUtil_GetConfigString(virConfPtr conf, const char *name, char **string,
- bool optional)
-{
- virConfValuePtr value;
-
- *string = NULL;
- value = virConfGetValue(conf, name);
-
- if (value == NULL) {
- if (optional) {
- return 0;
- }
-
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Missing essential config entry '%s'"), name);
- return -1;
- }
-
- if (value->type != VIR_CONF_STRING) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Config entry '%s' must be a string"), name);
- return -1;
- }
-
- if (value->str == NULL) {
- if (optional) {
- return 0;
- }
-
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Missing essential config entry '%s'"), name);
- return -1;
- }
-
- *string = strdup(value->str);
-
- if (*string == NULL) {
- virReportOOMError();
- return -1;
- }
-
- return 0;
-}
-
-
-
-int
-esxUtil_GetConfigUUID(virConfPtr conf, const char *name, unsigned char *uuid,
- bool optional)
-{
- virConfValuePtr value;
-
- value = virConfGetValue(conf, name);
-
- if (value == NULL) {
- if (optional) {
- return 0;
- } else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Missing essential config entry '%s'"), name);
- return -1;
- }
- }
-
- if (value->type != VIR_CONF_STRING) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Config entry '%s' must be a string"), name);
- return -1;
- }
-
- if (value->str == NULL) {
- if (optional) {
- return 0;
- } else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Missing essential config entry '%s'"), name);
- return -1;
- }
- }
-
- if (virUUIDParse(value->str, uuid) < 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Could not parse UUID from string '%s'"), value->str);
- return -1;
- }
-
- return 0;
-}
-
-
-
-int
-esxUtil_GetConfigLong(virConfPtr conf, const char *name, long long *number,
- long long default_, bool optional)
-{
- virConfValuePtr value;
-
- *number = default_;
- value = virConfGetValue(conf, name);
-
- if (value == NULL) {
- if (optional) {
- return 0;
- } else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Missing essential config entry '%s'"), name);
- return -1;
- }
- }
-
- if (value->type == VIR_CONF_STRING) {
- if (value->str == NULL) {
- if (optional) {
- return 0;
- } else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Missing essential config entry '%s'"), name);
- return -1;
- }
- }
-
- if (STREQ(value->str, "unlimited")) {
- *number = -1;
- } else if (virStrToLong_ll(value->str, NULL, 10, number) < 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Config entry '%s' must represent an integer value"),
- name);
- return -1;
- }
- } else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Config entry '%s' must be a string"), name);
- return -1;
- }
-
- return 0;
-}
-
-
-
-int
-esxUtil_GetConfigBoolean(virConfPtr conf, const char *name, bool *boolean_,
- bool default_, bool optional)
-{
- virConfValuePtr value;
-
- *boolean_ = default_;
- value = virConfGetValue(conf, name);
-
- if (value == NULL) {
- if (optional) {
- return 0;
- } else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Missing essential config entry '%s'"), name);
- return -1;
- }
- }
-
- if (value->type == VIR_CONF_STRING) {
- if (value->str == NULL) {
- if (optional) {
- return 0;
- } else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Missing essential config entry '%s'"), name);
- return -1;
- }
- }
-
- if (STRCASEEQ(value->str, "true")) {
- *boolean_ = 1;
- } else if (STRCASEEQ(value->str, "false")) {
- *boolean_ = 0;
- } else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Config entry '%s' must represent a boolean value "
- "(true|false)"), name);
- return -1;
- }
- } else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Config entry '%s' must be a string"), name);
- return -1;
- }
-
- return 0;
-}
-
-
-
-int
esxUtil_ReformatUuid(const char *input, char *output)
{
unsigned char uuid[VIR_UUID_BUFLEN];
@@ -626,81 +434,6 @@ esxUtil_ReformatUuid(const char *input, char *output)
char *
-esxUtil_EscapeHex(const char *string, char escape, const char *special)
-{
- char *escaped = NULL;
- size_t length = 1; /* 1 byte for termination */
- const char *tmp1 = string;
- char *tmp2;
-
- /* Calculate length of escaped string */
- while (*tmp1 != '\0') {
- if (*tmp1 == escape || strspn(tmp1, special) > 0) {
- length += 2;
- }
-
- ++tmp1;
- ++length;
- }
-
- if (VIR_ALLOC_N(escaped, length) < 0) {
- virReportOOMError();
- return NULL;
- }
-
- tmp1 = string; /* reading from this one */
- tmp2 = escaped; /* writing to this one */
-
- /* Escape to 'cXX' where c is the escape char and X is a hex digit */
- while (*tmp1 != '\0') {
- if (*tmp1 == escape || strspn(tmp1, special) > 0) {
- *tmp2++ = escape;
-
- snprintf(tmp2, 3, "%02x", (unsigned int)*tmp1);
-
- tmp2 += 2;
- } else {
- *tmp2++ = *tmp1;
- }
-
- ++tmp1;
- }
-
- *tmp2 = '\0';
-
- return escaped;
-}
-
-
-
-int
-esxUtil_UnescapeHex(char *string, char escape)
-{
- char *tmp1 = string; /* reading from this one */
- char *tmp2 = string; /* writing to this one */
-
- /* Unescape from 'cXX' where c is the escape char and X is a hex digit */
- while (*tmp1 != '\0') {
- if (*tmp1 == escape) {
- if (!c_isxdigit(tmp1[1]) || !c_isxdigit(tmp1[2])) {
- return -1;
- }
-
- *tmp2++ = virHexToBin(tmp1[1]) * 16 + virHexToBin(tmp1[2]);
- tmp1 += 3;
- } else {
- *tmp2++ = *tmp1++;
- }
- }
-
- *tmp2 = '\0';
-
- return 0;
-}
-
-
-
-char *
esxUtil_EscapeBase64(const char *string)
{
/* 'normal' characters don't get base64 encoded */
@@ -805,7 +538,7 @@ esxUtil_EscapeDatastoreItem(const char *string)
esxUtil_ReplaceSpecialWindowsPathChars(replaced);
- escaped1 = esxUtil_EscapeHexPercent(replaced);
+ escaped1 = virVMXEscapeHexPercent(replaced);
if (escaped1 == NULL) {
goto cleanup;
@@ -819,41 +552,3 @@ esxUtil_EscapeDatastoreItem(const char *string)
return escaped2;
}
-
-
-
-char *
-esxUtil_ConvertToUTF8(const char *encoding, const char *string)
-{
- char *result = NULL;
- xmlCharEncodingHandlerPtr handler;
- xmlBufferPtr input;
- xmlBufferPtr utf8;
-
- handler = xmlFindCharEncodingHandler(encoding);
-
- if (handler == NULL) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("libxml2 doesn't handle %s encoding"), encoding);
- return NULL;
- }
-
- input = xmlBufferCreateStatic((char *)string, strlen(string));
- utf8 = xmlBufferCreate();
-
- if (xmlCharEncInFunc(handler, utf8, input) < 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Could not convert from %s to UTF-8 encoding"), encoding);
- goto cleanup;
- }
-
- result = (char *)utf8->content;
- utf8->content = NULL;
-
- cleanup:
- xmlCharEncCloseFunc(handler);
- xmlBufferFree(input);
- xmlBufferFree(utf8);
-
- return result;
-}
diff --git a/src/esx/esx_util.h b/src/esx/esx_util.h
index 694e935..4cbf9b7 100644
--- a/src/esx/esx_util.h
+++ b/src/esx/esx_util.h
@@ -27,7 +27,6 @@
# include <libxml/uri.h>
# include "internal.h"
-# include "conf.h"
typedef struct _esxUtil_ParsedUri esxUtil_ParsedUri;
@@ -57,38 +56,12 @@ int esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
int esxUtil_ResolveHostname(const char *hostname,
char *ipAddress, size_t ipAddress_length);
-int esxUtil_GetConfigString(virConfPtr conf, const char *name, char **string,
- bool optional);
-
-int esxUtil_GetConfigUUID(virConfPtr conf, const char *name,
- unsigned char *uuid, bool optional);
-
-int esxUtil_GetConfigLong(virConfPtr conf, const char *name, long long *number,
- long long default_, bool optional);
-
-int esxUtil_GetConfigBoolean(virConfPtr conf, const char *name, bool *boolean_,
- bool default_, bool optional);
-
int esxUtil_ReformatUuid(const char *input, char *output);
-char *esxUtil_EscapeHex(const char *string, char escape, const char *special);
-
-# define esxUtil_EscapeHexPipe(_string) esxUtil_EscapeHex(_string, '|', "\"")
-
-# define esxUtil_EscapeHexPercent(_string) esxUtil_EscapeHex(_string, '%', "/\\")
-
-int esxUtil_UnescapeHex(char *string, char escape);
-
-# define esxUtil_UnescapeHexPipe(_string) esxUtil_UnescapeHex(_string, '|')
-
-# define esxUtil_UnescapeHexPercent(_string) esxUtil_UnescapeHex(_string, '%')
-
char *esxUtil_EscapeBase64(const char *string);
void esxUtil_ReplaceSpecialWindowsPathChars(char *string);
char *esxUtil_EscapeDatastoreItem(const char *string);
-char *esxUtil_ConvertToUTF8(const char *encoding, const char *string);
-
#endif /* __ESX_UTIL_H__ */
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 482a118..76be5a4 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -31,6 +31,7 @@
#include "logging.h"
#include "util.h"
#include "uuid.h"
+#include "vmx.h"
#include "xml.h"
#include "esx_vi.h"
#include "esx_vi_methods.h"
@@ -2048,7 +2049,7 @@ esxVI_GetVirtualMachineIdentity(esxVI_ObjectContent *virtualMachine,
goto failure;
}
- if (esxUtil_UnescapeHexPercent(*name) < 0) {
+ if (virVMXUnescapeHexPercent(*name) < 0) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
_("Domain name contains invalid escape sequence"));
goto failure;
@@ -3723,3 +3724,40 @@ esxVI_ParseHostCpuIdInfo(esxVI_ParsedHostCpuIdInfo *parsedHostCpuIdInfo,
return 0;
}
+
+
+
+int
+esxVI_ProductVersionToDefaultVirtualHWVersion(esxVI_ProductVersion productVersion)
+{
+ /*
+ * virtualHW.version compatibility matrix:
+ *
+ * 4 7 API
+ * ESX 3.5 + 2.5
+ * ESX 4.0 + + 4.0
+ * ESX 4.1 + + 4.1
+ * GSX 2.0 + + 2.5
+ */
+ switch (productVersion) {
+ case esxVI_ProductVersion_ESX35:
+ case esxVI_ProductVersion_VPX25:
+ return 4;
+
+ case esxVI_ProductVersion_GSX20:
+ case esxVI_ProductVersion_ESX40:
+ case esxVI_ProductVersion_ESX41:
+ case esxVI_ProductVersion_VPX40:
+ case esxVI_ProductVersion_VPX41:
+ return 7;
+
+ case esxVI_ProductVersion_ESX4x:
+ case esxVI_ProductVersion_VPX4x:
+ return 7;
+
+ default:
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Unexpected product version"));
+ return -1;
+ }
+}
diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h
index 20e6fb5..d512add 100644
--- a/src/esx/esx_vi.h
+++ b/src/esx/esx_vi.h
@@ -435,4 +435,6 @@ int esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
int esxVI_ParseHostCpuIdInfo(esxVI_ParsedHostCpuIdInfo *parsedHostCpuIdInfo,
esxVI_HostCpuIdInfo *hostCpuIdInfo);
+int esxVI_ProductVersionToDefaultVirtualHWVersion(esxVI_ProductVersion productVersion);
+
#endif /* __ESX_VI_H__ */
diff --git a/src/esx/esx_vmx.h b/src/esx/esx_vmx.h
deleted file mode 100644
index 12fc5af..0000000
--- a/src/esx/esx_vmx.h
+++ /dev/null
@@ -1,154 +0,0 @@
-
-/*
- * esx_vmx.h: VMX related functions for the VMware ESX driver
- *
- * Copyright (C) 2009 Matthias Bolte <matthias.bolte(a)googlemail.com>
- *
- * 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
- *
- */
-
-#ifndef __ESX_VMX_H__
-# define __ESX_VMX_H__
-
-# include <stdbool.h>
-
-# include "internal.h"
-# include "conf.h"
-# include "domain_conf.h"
-# include "esx_vi.h"
-
-typedef struct _esxVMX_Context esxVMX_Context;
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Context
- */
-
-typedef char * (*esxVMX_ParseFileName)(const char *fileName, void *opaque);
-typedef char * (*esxVMX_FormatFileName)(const char *src, void *opaque);
-typedef int (*esxVMX_AutodetectSCSIControllerModel)(virDomainDiskDefPtr def,
- int *model, void *opaque);
-
-/*
- * esxVMX_ParseFileName is only used by esxVMX_ParseConfig.
- * esxVMX_FormatFileName is only used by esxVMX_FormatConfig.
- * esxVMX_AutodetectSCSIControllerModel is optionally used by esxVMX_FormatConfig.
- */
-struct _esxVMX_Context {
- void *opaque;
- esxVMX_ParseFileName parseFileName;
- esxVMX_FormatFileName formatFileName;
- esxVMX_AutodetectSCSIControllerModel autodetectSCSIControllerModel;
-};
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Helpers
- */
-
-int
-esxVMX_SCSIDiskNameToControllerAndUnit(const char *name, int *controller,
- int *unit);
-
-int
-esxVMX_IDEDiskNameToBusAndUnit(const char *name, int *bus, int *unit);
-
-int
-esxVMX_FloppyDiskNameToUnit(const char *name, int *unit);
-
-int
-esxVMX_VerifyDiskAddress(virCapsPtr caps, virDomainDiskDefPtr disk);
-
-int
-esxVMX_HandleLegacySCSIDiskDriverName(virDomainDefPtr def,
- virDomainDiskDefPtr disk);
-
-int
-esxVMX_GatherSCSIControllers(esxVMX_Context *ctx, virDomainDefPtr def,
- int virtualDev[4], bool present[4]);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VMX -> Domain XML
- */
-
-virDomainDefPtr
-esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
- esxVI_ProductVersion productVersion);
-
-int
-esxVMX_ParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def);
-
-int
-esxVMX_ParseSCSIController(virConfPtr conf, int controller, bool *present,
- int *virtualDev);
-
-int
-esxVMX_ParseDisk(esxVMX_Context *ctx, virCapsPtr caps, virConfPtr conf,
- int device, int busType, int controllerOrBus, int unit,
- virDomainDiskDefPtr *def);
-int
-esxVMX_ParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def);
-
-int
-esxVMX_ParseSerial(esxVMX_Context *ctx, virConfPtr conf, int port,
- virDomainChrDefPtr *def);
-
-int
-esxVMX_ParseParallel(esxVMX_Context *ctx, virConfPtr conf, int port,
- virDomainChrDefPtr *def);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Domain XML -> VMX
- */
-
-char *
-esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
- esxVI_ProductVersion productVersion);
-
-int
-esxVMX_FormatVNC(virDomainGraphicsDefPtr def, virBufferPtr buffer);
-
-int
-esxVMX_FormatHardDisk(esxVMX_Context *ctx, virDomainDiskDefPtr def,
- virBufferPtr buffer);
-
-int
-esxVMX_FormatCDROM(esxVMX_Context *ctx, virDomainDiskDefPtr def,
- virBufferPtr buffer);
-
-int
-esxVMX_FormatFloppy(esxVMX_Context *ctx, virDomainDiskDefPtr def,
- virBufferPtr buffer, bool floppy_present[2]);
-
-int
-esxVMX_FormatEthernet(virDomainNetDefPtr def, int controller,
- virBufferPtr buffer);
-
-int
-esxVMX_FormatSerial(esxVMX_Context *ctx, virDomainChrDefPtr def,
- virBufferPtr buffer);
-
-int
-esxVMX_FormatParallel(esxVMX_Context *ctx, virDomainChrDefPtr def,
- virBufferPtr buffer);
-
-#endif /* __ESX_VMX_H__ */
diff --git a/src/libvirt_vmx.syms b/src/libvirt_vmx.syms
new file mode 100644
index 0000000..01252f8
--- /dev/null
+++ b/src/libvirt_vmx.syms
@@ -0,0 +1,23 @@
+#
+# These symbols are dependent upon --with-esx via WITH_ESX or --with-vmware via WITH_VMWARE.
+#
+
+# vmx.h
+virVMXConvertToUTF8;
+virVMXEscapeHex;
+virVMXUnescapeHex;
+virVMXParseConfig;
+virVMXParseVNC;
+virVMXParseSCSIController;
+virVMXParseDisk;
+virVMXParseEthernet;
+virVMXParseSerial;
+virVMXParseParallel;
+virVMXFormatConfig;
+virVMXFormatVNC;
+virVMXFormatHardDisk;
+virVMXFormatCDROM;
+virVMXFormatFloppy;
+virVMXFormatEthernet;
+virVMXFormatSerial;
+virVMXFormatParallel;
diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c
index 41747c9..c3f53ea 100644
--- a/src/vmware/vmware_conf.c
+++ b/src/vmware/vmware_conf.c
@@ -27,10 +27,10 @@
#include "dirname.h"
#include "memory.h"
#include "nodeinfo.h"
-#include "util/files.h"
+#include "files.h"
#include "uuid.h"
#include "virterror_internal.h"
-#include "../esx/esx_vmx.h"
+#include "vmx.h"
#include "vmware_conf.h"
@@ -137,13 +137,13 @@ vmwareLoadDomains(struct vmware_driver *driver)
char *directoryName = NULL;
char *fileName = NULL;
int ret = -1;
- esxVMX_Context ctx;
+ virVMXContext ctx;
char *outbuf = NULL;
char *str;
char *saveptr = NULL;
virCommandPtr cmd;
- ctx.parseFileName = esxCopyVMXFileName;
+ ctx.parseFileName = vmwareCopyVMXFileName;
cmd = virCommandNewArgList(VMRUN, "-T",
driver->type == TYPE_PLAYER ? "player" : "ws",
@@ -162,8 +162,7 @@ vmwareLoadDomains(struct vmware_driver *driver)
goto cleanup;
if ((vmdef =
- esxVMX_ParseConfig(&ctx, driver->caps, vmx,
- esxVI_ProductVersion_ESX4x)) == NULL) {
+ virVMXParseConfig(&ctx, driver->caps, vmx)) == NULL) {
goto cleanup;
}
@@ -487,7 +486,7 @@ cleanup:
}
char *
-esxCopyVMXFileName(const char *datastorePath, void *opaque ATTRIBUTE_UNUSED)
+vmwareCopyVMXFileName(const char *datastorePath, void *opaque ATTRIBUTE_UNUSED)
{
char *path = strdup(datastorePath);
diff --git a/src/vmware/vmware_conf.h b/src/vmware/vmware_conf.h
index b1cdf8f..e47ce62 100644
--- a/src/vmware/vmware_conf.h
+++ b/src/vmware/vmware_conf.h
@@ -78,6 +78,6 @@ int vmwareMakePath(char *srcDir, char *srcName, char *srcExt,
int vmwareExtractPid(const char * vmxPath);
-char * esxCopyVMXFileName(const char *datastorePath, void *opaque);
+char *vmwareCopyVMXFileName(const char *datastorePath, void *opaque);
#endif
diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index 9662f46..47314f8 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -21,15 +21,17 @@
#include <fcntl.h>
+#include "internal.h"
+#include "virterror_internal.h"
+#include "datatypes.h"
#include "files.h"
#include "memory.h"
#include "uuid.h"
-
-#include "../esx/esx_vmx.h"
+#include "vmx.h"
#include "vmware_conf.h"
#include "vmware_driver.h"
-const char *vmw_types[] = { "player", "ws" };
+static const char *vmw_types[] = { "player", "ws" };
static void
vmwareDriverLock(struct vmware_driver *driver)
@@ -244,9 +246,9 @@ vmwareDomainDefineXML(virConnectPtr conn, const char *xml)
char *fileName = NULL;
char *vmxPath = NULL;
vmwareDomainPtr pDomain = NULL;
- esxVMX_Context ctx;
+ virVMXContext ctx;
- ctx.formatFileName = esxCopyVMXFileName;
+ ctx.formatFileName = vmwareCopyVMXFileName;
vmwareDriverLock(driver);
if ((vmdef = virDomainDefParseString(driver->caps, xml,
@@ -257,8 +259,7 @@ vmwareDomainDefineXML(virConnectPtr conn, const char *xml)
goto cleanup;
/* generate vmx file */
- vmx = esxVMX_FormatConfig(&ctx, driver->caps, vmdef,
- esxVI_ProductVersion_ESX4x);
+ vmx = virVMXFormatConfig(&ctx, driver->caps, vmdef, 7);
if (vmx == NULL)
goto cleanup;
@@ -497,9 +498,9 @@ vmwareDomainCreateXML(virConnectPtr conn, const char *xml,
char *vmx = NULL;
char *vmxPath = NULL;
vmwareDomainPtr pDomain = NULL;
- esxVMX_Context ctx;
+ virVMXContext ctx;
- ctx.formatFileName = esxCopyVMXFileName;
+ ctx.formatFileName = vmwareCopyVMXFileName;
vmwareDriverLock(driver);
@@ -511,8 +512,7 @@ vmwareDomainCreateXML(virConnectPtr conn, const char *xml,
goto cleanup;
/* generate vmx file */
- vmx = esxVMX_FormatConfig(&ctx, driver->caps, vmdef,
- esxVI_ProductVersion_ESX4x);
+ vmx = virVMXFormatConfig(&ctx, driver->caps, vmdef, 7);
if (vmx == NULL)
goto cleanup;
diff --git a/src/esx/esx_vmx.c b/src/vmx/vmx.c
similarity index 79%
rename from src/esx/esx_vmx.c
rename to src/vmx/vmx.c
index 5cbb835..6e3e9af 100644
--- a/src/esx/esx_vmx.c
+++ b/src/vmx/vmx.c
@@ -1,9 +1,9 @@
/*
- * esx_vmx.c: VMX related functions for the VMware ESX driver
+ * vmx.c: VMware VMX parsing/formatting functions
*
* Copyright (C) 2010 Red Hat, Inc.
- * Copyright (C) 2009 Matthias Bolte <matthias.bolte(a)googlemail.com>
+ * Copyright (C) 2009-2010 Matthias Bolte <matthias.bolte(a)googlemail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -24,13 +24,15 @@
#include <config.h>
#include <c-ctype.h>
+#include <libxml/uri.h>
#include "internal.h"
#include "virterror_internal.h"
+#include "conf.h"
#include "memory.h"
#include "logging.h"
-#include "esx_private.h"
-#include "esx_vmx.h"
+#include "uuid.h"
+#include "vmx.h"
/*
@@ -454,19 +456,23 @@ def->parallels[0]...
*/
-#define VIR_FROM_THIS VIR_FROM_ESX
+#define VIR_FROM_THIS VIR_FROM_NONE
-#define ESX_BUILD_VMX_NAME_EXTRA(_suffix, _extra) \
+#define VMX_ERROR(code, ...) \
+ virReportErrorHelper(NULL, VIR_FROM_NONE, code, __FILE__, __FUNCTION__, \
+ __LINE__, __VA_ARGS__)
+
+#define VMX_BUILD_NAME_EXTRA(_suffix, _extra) \
snprintf(_suffix##_name, sizeof(_suffix##_name), "%s."_extra, prefix);
-#define ESX_BUILD_VMX_NAME(_suffix) \
- ESX_BUILD_VMX_NAME_EXTRA(_suffix, #_suffix)
+#define VMX_BUILD_NAME(_suffix) \
+ VMX_BUILD_NAME_EXTRA(_suffix, #_suffix)
-/* directly map the virDomainControllerModel to esxVMX_SCSIControllerModel,
+/* directly map the virDomainControllerModel to virVMXSCSIControllerModel,
* this is good enough for now because all virDomainControllerModel values
* are actually SCSI controller models in the ESX case */
-VIR_ENUM_DECL(esxVMX_SCSIControllerModel)
-VIR_ENUM_IMPL(esxVMX_SCSIControllerModel, VIR_DOMAIN_CONTROLLER_MODEL_LAST,
+VIR_ENUM_DECL(virVMXSCSIControllerModel)
+VIR_ENUM_IMPL(virVMXSCSIControllerModel, VIR_DOMAIN_CONTROLLER_MODEL_LAST,
"auto", /* just to match virDomainControllerModel, will never be used */
"buslogic",
"lsilogic",
@@ -479,13 +485,318 @@ VIR_ENUM_IMPL(esxVMX_SCSIControllerModel, VIR_DOMAIN_CONTROLLER_MODEL_LAST,
* Helpers
*/
+char *
+virVMXEscapeHex(const char *string, char escape, const char *special)
+{
+ char *escaped = NULL;
+ size_t length = 1; /* 1 byte for termination */
+ const char *tmp1 = string;
+ char *tmp2;
+
+ /* Calculate length of escaped string */
+ while (*tmp1 != '\0') {
+ if (*tmp1 == escape || strspn(tmp1, special) > 0) {
+ length += 2;
+ }
+
+ ++tmp1;
+ ++length;
+ }
+
+ if (VIR_ALLOC_N(escaped, length) < 0) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ tmp1 = string; /* reading from this one */
+ tmp2 = escaped; /* writing to this one */
+
+ /* Escape to 'cXX' where c is the escape char and X is a hex digit */
+ while (*tmp1 != '\0') {
+ if (*tmp1 == escape || strspn(tmp1, special) > 0) {
+ *tmp2++ = escape;
+
+ snprintf(tmp2, 3, "%02x", (unsigned int)*tmp1);
+
+ tmp2 += 2;
+ } else {
+ *tmp2++ = *tmp1;
+ }
+
+ ++tmp1;
+ }
+
+ *tmp2 = '\0';
+
+ return escaped;
+}
+
+
+
int
-esxVMX_SCSIDiskNameToControllerAndUnit(const char *name, int *controller, int *unit)
+virVMXUnescapeHex(char *string, char escape)
+{
+ char *tmp1 = string; /* reading from this one */
+ char *tmp2 = string; /* writing to this one */
+
+ /* Unescape from 'cXX' where c is the escape char and X is a hex digit */
+ while (*tmp1 != '\0') {
+ if (*tmp1 == escape) {
+ if (!c_isxdigit(tmp1[1]) || !c_isxdigit(tmp1[2])) {
+ return -1;
+ }
+
+ *tmp2++ = virHexToBin(tmp1[1]) * 16 + virHexToBin(tmp1[2]);
+ tmp1 += 3;
+ } else {
+ *tmp2++ = *tmp1++;
+ }
+ }
+
+ *tmp2 = '\0';
+
+ return 0;
+}
+
+
+
+char *
+virVMXConvertToUTF8(const char *encoding, const char *string)
+{
+ char *result = NULL;
+ xmlCharEncodingHandlerPtr handler;
+ xmlBufferPtr input;
+ xmlBufferPtr utf8;
+
+ handler = xmlFindCharEncodingHandler(encoding);
+
+ if (handler == NULL) {
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("libxml2 doesn't handle %s encoding"), encoding);
+ return NULL;
+ }
+
+ input = xmlBufferCreateStatic((char *)string, strlen(string));
+ utf8 = xmlBufferCreate();
+
+ if (xmlCharEncInFunc(handler, utf8, input) < 0) {
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Could not convert from %s to UTF-8 encoding"), encoding);
+ goto cleanup;
+ }
+
+ result = (char *)utf8->content;
+ utf8->content = NULL;
+
+ cleanup:
+ xmlCharEncCloseFunc(handler);
+ xmlBufferFree(input);
+ xmlBufferFree(utf8);
+
+ return result;
+}
+
+
+
+static int
+virVMXGetConfigString(virConfPtr conf, const char *name, char **string,
+ bool optional)
+{
+ virConfValuePtr value;
+
+ *string = NULL;
+ value = virConfGetValue(conf, name);
+
+ if (value == NULL) {
+ if (optional) {
+ return 0;
+ }
+
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Missing essential config entry '%s'"), name);
+ return -1;
+ }
+
+ if (value->type != VIR_CONF_STRING) {
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Config entry '%s' must be a string"), name);
+ return -1;
+ }
+
+ if (value->str == NULL) {
+ if (optional) {
+ return 0;
+ }
+
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Missing essential config entry '%s'"), name);
+ return -1;
+ }
+
+ *string = strdup(value->str);
+
+ if (*string == NULL) {
+ virReportOOMError();
+ return -1;
+ }
+
+ return 0;
+}
+
+
+
+static int
+virVMXGetConfigUUID(virConfPtr conf, const char *name, unsigned char *uuid,
+ bool optional)
+{
+ virConfValuePtr value;
+
+ value = virConfGetValue(conf, name);
+
+ if (value == NULL) {
+ if (optional) {
+ return 0;
+ } else {
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Missing essential config entry '%s'"), name);
+ return -1;
+ }
+ }
+
+ if (value->type != VIR_CONF_STRING) {
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Config entry '%s' must be a string"), name);
+ return -1;
+ }
+
+ if (value->str == NULL) {
+ if (optional) {
+ return 0;
+ } else {
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Missing essential config entry '%s'"), name);
+ return -1;
+ }
+ }
+
+ if (virUUIDParse(value->str, uuid) < 0) {
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Could not parse UUID from string '%s'"), value->str);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+
+static int
+virVMXGetConfigLong(virConfPtr conf, const char *name, long long *number,
+ long long default_, bool optional)
+{
+ virConfValuePtr value;
+
+ *number = default_;
+ value = virConfGetValue(conf, name);
+
+ if (value == NULL) {
+ if (optional) {
+ return 0;
+ } else {
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Missing essential config entry '%s'"), name);
+ return -1;
+ }
+ }
+
+ if (value->type == VIR_CONF_STRING) {
+ if (value->str == NULL) {
+ if (optional) {
+ return 0;
+ } else {
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Missing essential config entry '%s'"), name);
+ return -1;
+ }
+ }
+
+ if (STREQ(value->str, "unlimited")) {
+ *number = -1;
+ } else if (virStrToLong_ll(value->str, NULL, 10, number) < 0) {
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Config entry '%s' must represent an integer value"),
+ name);
+ return -1;
+ }
+ } else {
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Config entry '%s' must be a string"), name);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+
+static int
+virVMXGetConfigBoolean(virConfPtr conf, const char *name, bool *boolean_,
+ bool default_, bool optional)
+{
+ virConfValuePtr value;
+
+ *boolean_ = default_;
+ value = virConfGetValue(conf, name);
+
+ if (value == NULL) {
+ if (optional) {
+ return 0;
+ } else {
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Missing essential config entry '%s'"), name);
+ return -1;
+ }
+ }
+
+ if (value->type == VIR_CONF_STRING) {
+ if (value->str == NULL) {
+ if (optional) {
+ return 0;
+ } else {
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Missing essential config entry '%s'"), name);
+ return -1;
+ }
+ }
+
+ if (STRCASEEQ(value->str, "true")) {
+ *boolean_ = 1;
+ } else if (STRCASEEQ(value->str, "false")) {
+ *boolean_ = 0;
+ } else {
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Config entry '%s' must represent a boolean value "
+ "(true|false)"), name);
+ return -1;
+ }
+ } else {
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Config entry '%s' must be a string"), name);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+
+static int
+virVMXSCSIDiskNameToControllerAndUnit(const char *name, int *controller, int *unit)
{
int idx;
if (! STRPREFIX(name, "sd")) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
_("Expecting domain XML attribute 'dev' of entry "
"'devices/disk/target' to start with 'sd'"));
return -1;
@@ -494,14 +805,14 @@ esxVMX_SCSIDiskNameToControllerAndUnit(const char *name, int *controller, int *u
idx = virDiskNameToIndex(name);
if (idx < 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Could not parse valid disk index from '%s'"), name);
return -1;
}
/* Each of the 4 SCSI controllers has 1 bus with 15 units each for devices */
if (idx >= (4 * 15)) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("SCSI disk index (parsed from '%s') is too large"), name);
return -1;
}
@@ -519,13 +830,13 @@ esxVMX_SCSIDiskNameToControllerAndUnit(const char *name, int *controller, int *u
-int
-esxVMX_IDEDiskNameToBusAndUnit(const char *name, int *bus, int *unit)
+static int
+virVMXIDEDiskNameToBusAndUnit(const char *name, int *bus, int *unit)
{
int idx;
if (! STRPREFIX(name, "hd")) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
_("Expecting domain XML attribute 'dev' of entry "
"'devices/disk/target' to start with 'hd'"));
return -1;
@@ -534,14 +845,14 @@ esxVMX_IDEDiskNameToBusAndUnit(const char *name, int *bus, int *unit)
idx = virDiskNameToIndex(name);
if (idx < 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Could not parse valid disk index from '%s'"), name);
return -1;
}
/* The IDE controller has 2 buses with 2 units each for devices */
if (idx >= (2 * 2)) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("IDE disk index (parsed from '%s') is too large"), name);
return -1;
}
@@ -554,13 +865,13 @@ esxVMX_IDEDiskNameToBusAndUnit(const char *name, int *bus, int *unit)
-int
-esxVMX_FloppyDiskNameToUnit(const char *name, int *unit)
+static int
+virVMXFloppyDiskNameToUnit(const char *name, int *unit)
{
int idx;
if (! STRPREFIX(name, "fd")) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
_("Expecting domain XML attribute 'dev' of entry "
"'devices/disk/target' to start with 'fd'"));
return -1;
@@ -569,14 +880,14 @@ esxVMX_FloppyDiskNameToUnit(const char *name, int *unit)
idx = virDiskNameToIndex(name);
if (idx < 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Could not parse valid disk index from '%s'"), name);
return -1;
}
/* The FDC controller has 1 bus with 2 units for devices */
if (idx >= 2) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Floppy disk index (parsed from '%s') is too large"), name);
return -1;
}
@@ -588,8 +899,8 @@ esxVMX_FloppyDiskNameToUnit(const char *name, int *unit)
-int
-esxVMX_VerifyDiskAddress(virCapsPtr caps, virDomainDiskDefPtr disk)
+static int
+virVMXVerifyDiskAddress(virCapsPtr caps, virDomainDiskDefPtr disk)
{
virDomainDiskDef def;
virDomainDeviceDriveAddressPtr drive;
@@ -597,7 +908,7 @@ esxVMX_VerifyDiskAddress(virCapsPtr caps, virDomainDiskDefPtr disk)
memset(&def, 0, sizeof(def));
if (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Unsupported disk address type '%s'"),
virDomainDeviceAddressTypeToString(disk->info.type));
return -1;
@@ -609,7 +920,7 @@ esxVMX_VerifyDiskAddress(virCapsPtr caps, virDomainDiskDefPtr disk)
def.bus = disk->bus;
if (virDomainDiskDefAssignAddress(caps, &def) < 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not verify disk address"));
return -1;
}
@@ -617,7 +928,7 @@ esxVMX_VerifyDiskAddress(virCapsPtr caps, virDomainDiskDefPtr disk)
if (def.info.addr.drive.controller != drive->controller ||
def.info.addr.drive.bus != drive->bus ||
def.info.addr.drive.unit != drive->unit) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Disk address %d:%d:%d doesn't match target device '%s'"),
drive->controller, drive->bus, drive->unit, disk->dst);
return -1;
@@ -626,69 +937,69 @@ esxVMX_VerifyDiskAddress(virCapsPtr caps, virDomainDiskDefPtr disk)
/* drive->{controller|bus|unit} is unsigned, no >= 0 checks are necessary */
if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI) {
if (drive->controller > 3) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("SCSI controller index %d out of [0..3] range"),
drive->controller);
return -1;
}
if (drive->bus != 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("SCSI bus index %d out of [0] range"),
drive->bus);
return -1;
}
if (drive->unit > 15 || drive->unit == 7) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("SCSI unit index %d out of [0..6,8..15] range"),
drive->unit);
return -1;
}
} else if (disk->bus == VIR_DOMAIN_DISK_BUS_IDE) {
if (drive->controller != 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("IDE controller index %d out of [0] range"),
drive->controller);
return -1;
}
if (drive->bus > 1) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("IDE bus index %d out of [0..1] range"),
drive->bus);
return -1;
}
if (drive->unit > 1) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("IDE unit index %d out of [0..1] range"),
drive->unit);
return -1;
}
} else if (disk->bus == VIR_DOMAIN_DISK_BUS_FDC) {
if (drive->controller != 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("FDC controller index %d out of [0] range"),
drive->controller);
return -1;
}
if (drive->bus != 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("FDC bus index %d out of [0] range"),
drive->bus);
return -1;
}
if (drive->unit > 1) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("FDC unit index %d out of [0..1] range"),
drive->unit);
return -1;
}
} else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Unsupported bus type '%s'"),
virDomainDiskBusTypeToString(disk->bus));
return -1;
@@ -699,9 +1010,9 @@ esxVMX_VerifyDiskAddress(virCapsPtr caps, virDomainDiskDefPtr disk)
-int
-esxVMX_HandleLegacySCSIDiskDriverName(virDomainDefPtr def,
- virDomainDiskDefPtr disk)
+static int
+virVMXHandleLegacySCSIDiskDriverName(virDomainDefPtr def,
+ virDomainDiskDefPtr disk)
{
char *tmp;
int model, i;
@@ -720,7 +1031,7 @@ esxVMX_HandleLegacySCSIDiskDriverName(virDomainDefPtr def,
model = virDomainControllerModelTypeFromString(disk->driverName);
if (model < 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Unknown driver name '%s'"), disk->driverName);
return -1;
}
@@ -733,7 +1044,7 @@ esxVMX_HandleLegacySCSIDiskDriverName(virDomainDefPtr def,
}
if (controller == NULL) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Missing SCSI controller for index %d"),
disk->info.addr.drive.controller);
return -1;
@@ -742,7 +1053,7 @@ esxVMX_HandleLegacySCSIDiskDriverName(virDomainDefPtr def,
if (controller->model == -1) {
controller->model = model;
} else if (controller->model != model) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Inconsistent SCSI controller model ('%s' is not '%s') "
"for SCSI controller index %d"), disk->driverName,
virDomainControllerModelTypeToString(controller->model),
@@ -755,9 +1066,9 @@ esxVMX_HandleLegacySCSIDiskDriverName(virDomainDefPtr def,
-int
-esxVMX_GatherSCSIControllers(esxVMX_Context *ctx, virDomainDefPtr def,
- int virtualDev[4], bool present[4])
+static int
+virVMXGatherSCSIControllers(virVMXContext *ctx, virDomainDefPtr def,
+ int virtualDev[4], bool present[4])
{
int result = -1;
int i, k;
@@ -822,7 +1133,7 @@ esxVMX_GatherSCSIControllers(esxVMX_Context *ctx, virDomainDefPtr def,
// have inconsistent SCSI controller models
for (k = 0; k < count; ++k) {
if (autodetectedModels[k] != autodetectedModels[0]) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Disks on SCSI controller %d have inconsistent "
"controller models, cannot autodetect model"),
controller->idx);
@@ -838,7 +1149,7 @@ esxVMX_GatherSCSIControllers(esxVMX_Context *ctx, virDomainDefPtr def,
controller->model != VIR_DOMAIN_CONTROLLER_MODEL_LSILOGIC &&
controller->model != VIR_DOMAIN_CONTROLLER_MODEL_LSISAS1068 &&
controller->model != VIR_DOMAIN_CONTROLLER_MODEL_VMPVSCSI) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting domain XML attribute 'model' of entry "
"'controller' to be 'buslogic' or 'lsilogic' or "
"'lsisas1068' or 'vmpvscsi' but found '%s'"),
@@ -865,8 +1176,7 @@ esxVMX_GatherSCSIControllers(esxVMX_Context *ctx, virDomainDefPtr def,
*/
virDomainDefPtr
-esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
- esxVI_ProductVersion productVersion)
+virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx)
{
bool success = false;
virConfPtr conf = NULL;
@@ -890,8 +1200,8 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
int unit;
if (ctx->parseFileName == NULL) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
- _("esxVMX_Context has no parseFileName function set"));
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("virVMXContext has no parseFileName function set"));
return NULL;
}
@@ -902,7 +1212,7 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
}
/* vmx:.encoding */
- if (esxUtil_GetConfigString(conf, ".encoding", &encoding, true) < 0) {
+ if (virVMXGetConfigString(conf, ".encoding", &encoding, true) < 0) {
goto cleanup;
}
@@ -912,7 +1222,7 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
virConfFree(conf);
conf = NULL;
- utf8 = esxUtil_ConvertToUTF8(encoding, vmx);
+ utf8 = virVMXConvertToUTF8(encoding, vmx);
if (utf8 == NULL) {
goto cleanup;
@@ -933,104 +1243,65 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
return NULL;
}
- def->virtType = VIR_DOMAIN_VIRT_VMWARE; /* FIXME: maybe add VIR_DOMAIN_VIRT_ESX ? */
+ def->virtType = VIR_DOMAIN_VIRT_VMWARE;
def->id = -1;
/* vmx:config.version */
- if (esxUtil_GetConfigLong(conf, "config.version", &config_version, 0,
- false) < 0) {
+ if (virVMXGetConfigLong(conf, "config.version", &config_version, 0,
+ false) < 0) {
goto cleanup;
}
if (config_version != 8) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry 'config.version' to be 8 but found "
"%lld"), config_version);
goto cleanup;
}
/* vmx:virtualHW.version */
- if (esxUtil_GetConfigLong(conf, "virtualHW.version", &virtualHW_version, 0,
- false) < 0) {
+ if (virVMXGetConfigLong(conf, "virtualHW.version", &virtualHW_version, 0,
+ false) < 0) {
goto cleanup;
}
- /*
- * virtualHW.version compatibility matrix:
- *
- * 4 7 API
- * ESX 3.5 + 2.5
- * ESX 4.0 + + 4.0
- * ESX 4.1 + + 4.1
- * GSX 2.0 + + 2.5
- */
- switch (productVersion) {
- case esxVI_ProductVersion_ESX35:
- case esxVI_ProductVersion_VPX25:
- if (virtualHW_version != 4) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Expecting VMX entry 'virtualHW.version' to be 4 "
- "but found %lld"),
- virtualHW_version);
- goto cleanup;
- }
-
- break;
-
- case esxVI_ProductVersion_GSX20:
- case esxVI_ProductVersion_ESX40:
- case esxVI_ProductVersion_ESX41:
- case esxVI_ProductVersion_VPX40:
- case esxVI_ProductVersion_VPX41:
- if (virtualHW_version != 4 && virtualHW_version != 7) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Expecting VMX entry 'virtualHW.version' to be 4 or 7 "
- "but found %lld"),
- virtualHW_version);
- goto cleanup;
- }
-
- break;
-
- case esxVI_ProductVersion_ESX4x:
- case esxVI_ProductVersion_VPX4x:
- break;
-
- default:
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Unexpected product version"));
+ if (virtualHW_version != 4 && virtualHW_version != 7) {
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Expecting VMX entry 'virtualHW.version' to be 4 or 7 "
+ "but found %lld"),
+ virtualHW_version);
goto cleanup;
}
/* vmx:uuid.bios -> def:uuid */
/* FIXME: Need to handle 'uuid.action = "create"' */
- if (esxUtil_GetConfigUUID(conf, "uuid.bios", def->uuid, true) < 0) {
+ if (virVMXGetConfigUUID(conf, "uuid.bios", def->uuid, true) < 0) {
goto cleanup;
}
/* vmx:displayName -> def:name */
- if (esxUtil_GetConfigString(conf, "displayName", &def->name, true) < 0) {
+ if (virVMXGetConfigString(conf, "displayName", &def->name, true) < 0) {
goto cleanup;
}
if (def->name != NULL) {
- if (esxUtil_UnescapeHexPercent(def->name) < 0 ||
- esxUtil_UnescapeHexPipe(def->name) < 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ if (virVMXUnescapeHexPercent(def->name) < 0 ||
+ virVMXUnescapeHexPipe(def->name) < 0) {
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
_("VMX entry 'name' contains invalid escape sequence"));
goto cleanup;
}
}
/* vmx:annotation -> def:description */
- if (esxUtil_GetConfigString(conf, "annotation", &def->description,
- true) < 0) {
+ if (virVMXGetConfigString(conf, "annotation", &def->description,
+ true) < 0) {
goto cleanup;
}
if (def->description != NULL) {
- if (esxUtil_UnescapeHexPipe(def->description) < 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ if (virVMXUnescapeHexPipe(def->description) < 0) {
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
_("VMX entry 'annotation' contains invalid escape "
"sequence"));
goto cleanup;
@@ -1038,12 +1309,12 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
}
/* vmx:memsize -> def:mem.max_balloon */
- if (esxUtil_GetConfigLong(conf, "memsize", &memsize, 32, true) < 0) {
+ if (virVMXGetConfigLong(conf, "memsize", &memsize, 32, true) < 0) {
goto cleanup;
}
if (memsize <= 0 || memsize % 4 != 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry 'memsize' to be an unsigned "
"integer (multiple of 4) but found %lld"), memsize);
goto cleanup;
@@ -1052,8 +1323,8 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
def->mem.max_balloon = memsize * 1024; /* Scale from megabytes to kilobytes */
/* vmx:sched.mem.max -> def:mem.cur_balloon */
- if (esxUtil_GetConfigLong(conf, "sched.mem.max", &sched_mem_max, memsize,
- true) < 0) {
+ if (virVMXGetConfigLong(conf, "sched.mem.max", &sched_mem_max, memsize,
+ true) < 0) {
goto cleanup;
}
@@ -1068,8 +1339,8 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
}
/* vmx:sched.mem.minsize -> def:mem.min_guarantee */
- if (esxUtil_GetConfigLong(conf, "sched.mem.minsize", &sched_mem_minsize, 0,
- true) < 0) {
+ if (virVMXGetConfigLong(conf, "sched.mem.minsize", &sched_mem_minsize, 0,
+ true) < 0) {
goto cleanup;
}
@@ -1084,12 +1355,12 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
}
/* vmx:numvcpus -> def:vcpus */
- if (esxUtil_GetConfigLong(conf, "numvcpus", &numvcpus, 1, true) < 0) {
+ if (virVMXGetConfigLong(conf, "numvcpus", &numvcpus, 1, true) < 0) {
goto cleanup;
}
if (numvcpus <= 0 || (numvcpus % 2 != 0 && numvcpus != 1)) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry 'numvcpus' to be an unsigned "
"integer (1 or a multiple of 2) but found %lld"), numvcpus);
goto cleanup;
@@ -1099,8 +1370,8 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
/* vmx:sched.cpu.affinity -> def:cpumask */
// VirtualMachine:config.cpuAffinity.affinitySet
- if (esxUtil_GetConfigString(conf, "sched.cpu.affinity", &sched_cpu_affinity,
- true) < 0) {
+ if (virVMXGetConfigString(conf, "sched.cpu.affinity", &sched_cpu_affinity,
+ true) < 0) {
goto cleanup;
}
@@ -1121,7 +1392,7 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
number = virParseNumber(¤t);
if (number < 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry 'sched.cpu.affinity' to be "
"a comma separated list of unsigned integers but "
"found '%s'"), sched_cpu_affinity);
@@ -1129,7 +1400,7 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
}
if (number >= VIR_DOMAIN_CPUMASK_LEN) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("VMX entry 'sched.cpu.affinity' contains a %d, "
"this value is too large"), number);
goto cleanup;
@@ -1149,7 +1420,7 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
} else if (*current == '\0') {
break;
} else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry 'sched.cpu.affinity' to be "
"a comma separated list of unsigned integers but "
"found '%s'"), sched_cpu_affinity);
@@ -1160,7 +1431,7 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
}
if (count < numvcpus) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry 'sched.cpu.affinity' to contain "
"at least as many values as 'numvcpus' (%lld) but "
"found only %d value(s)"), numvcpus, count);
@@ -1182,7 +1453,7 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
}
/* vmx:guestOS -> def:os.arch */
- if (esxUtil_GetConfigString(conf, "guestOS", &guestOS, true) < 0) {
+ if (virVMXGetConfigString(conf, "guestOS", &guestOS, true) < 0) {
goto cleanup;
}
@@ -1198,8 +1469,8 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
}
/* vmx:smbios.reflecthost -> def:os.smbios_mode */
- if (esxUtil_GetConfigBoolean(conf, "smbios.reflecthost",
- &smbios_reflecthost, false, true) < 0) {
+ if (virVMXGetConfigBoolean(conf, "smbios.reflecthost",
+ &smbios_reflecthost, false, true) < 0) {
goto cleanup;
}
@@ -1221,7 +1492,7 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
def->ngraphics = 0;
- if (esxVMX_ParseVNC(conf, &def->graphics[def->ngraphics]) < 0) {
+ if (virVMXParseVNC(conf, &def->graphics[def->ngraphics]) < 0) {
goto cleanup;
}
@@ -1239,8 +1510,8 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
/* def:disks (scsi) */
for (controller = 0; controller < 4; ++controller) {
- if (esxVMX_ParseSCSIController(conf, controller, &present,
- &scsi_virtualDev[controller]) < 0) {
+ if (virVMXParseSCSIController(conf, controller, &present,
+ &scsi_virtualDev[controller]) < 0) {
goto cleanup;
}
@@ -1257,9 +1528,9 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
continue;
}
- if (esxVMX_ParseDisk(ctx, caps, conf, VIR_DOMAIN_DISK_DEVICE_DISK,
- VIR_DOMAIN_DISK_BUS_SCSI, controller, unit,
- &def->disks[def->ndisks]) < 0) {
+ if (virVMXParseDisk(ctx, caps, conf, VIR_DOMAIN_DISK_DEVICE_DISK,
+ VIR_DOMAIN_DISK_BUS_SCSI, controller, unit,
+ &def->disks[def->ndisks]) < 0) {
goto cleanup;
}
@@ -1268,7 +1539,7 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
continue;
}
- if (esxVMX_ParseDisk(ctx, caps, conf, VIR_DOMAIN_DISK_DEVICE_CDROM,
+ if (virVMXParseDisk(ctx, caps, conf, VIR_DOMAIN_DISK_DEVICE_CDROM,
VIR_DOMAIN_DISK_BUS_SCSI, controller, unit,
&def->disks[def->ndisks]) < 0) {
goto cleanup;
@@ -1283,9 +1554,9 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
/* def:disks (ide) */
for (bus = 0; bus < 2; ++bus) {
for (unit = 0; unit < 2; ++unit) {
- if (esxVMX_ParseDisk(ctx, caps, conf, VIR_DOMAIN_DISK_DEVICE_DISK,
- VIR_DOMAIN_DISK_BUS_IDE, bus, unit,
- &def->disks[def->ndisks]) < 0) {
+ if (virVMXParseDisk(ctx, caps, conf, VIR_DOMAIN_DISK_DEVICE_DISK,
+ VIR_DOMAIN_DISK_BUS_IDE, bus, unit,
+ &def->disks[def->ndisks]) < 0) {
goto cleanup;
}
@@ -1294,9 +1565,9 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
continue;
}
- if (esxVMX_ParseDisk(ctx, caps, conf, VIR_DOMAIN_DISK_DEVICE_CDROM,
- VIR_DOMAIN_DISK_BUS_IDE, bus, unit,
- &def->disks[def->ndisks]) < 0) {
+ if (virVMXParseDisk(ctx, caps, conf, VIR_DOMAIN_DISK_DEVICE_CDROM,
+ VIR_DOMAIN_DISK_BUS_IDE, bus, unit,
+ &def->disks[def->ndisks]) < 0) {
goto cleanup;
}
@@ -1308,9 +1579,9 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
/* def:disks (floppy) */
for (unit = 0; unit < 2; ++unit) {
- if (esxVMX_ParseDisk(ctx, caps, conf, VIR_DOMAIN_DISK_DEVICE_FLOPPY,
- VIR_DOMAIN_DISK_BUS_FDC, 0, unit,
- &def->disks[def->ndisks]) < 0) {
+ if (virVMXParseDisk(ctx, caps, conf, VIR_DOMAIN_DISK_DEVICE_FLOPPY,
+ VIR_DOMAIN_DISK_BUS_FDC, 0, unit,
+ &def->disks[def->ndisks]) < 0) {
goto cleanup;
}
@@ -1321,7 +1592,7 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
/* def:controllers */
if (virDomainDefAddImplicitControllers(def) < 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not add controllers"));
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not add controllers"));
goto cleanup;
}
@@ -1329,7 +1600,7 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
if (def->controllers[controller]->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) {
if (def->controllers[controller]->idx < 0 ||
def->controllers[controller]->idx > 3) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("SCSI controller index %d out of [0..3] range"),
def->controllers[controller]->idx);
goto cleanup;
@@ -1352,8 +1623,8 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
def->nnets = 0;
for (controller = 0; controller < 4; ++controller) {
- if (esxVMX_ParseEthernet(conf, controller,
- &def->nets[def->nnets]) < 0) {
+ if (virVMXParseEthernet(conf, controller,
+ &def->nets[def->nnets]) < 0) {
goto cleanup;
}
@@ -1380,8 +1651,8 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
def->nserials = 0;
for (port = 0; port < 4; ++port) {
- if (esxVMX_ParseSerial(ctx, conf, port,
- &def->serials[def->nserials]) < 0) {
+ if (virVMXParseSerial(ctx, conf, port,
+ &def->serials[def->nserials]) < 0) {
goto cleanup;
}
@@ -1399,8 +1670,8 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
def->nparallels = 0;
for (port = 0; port < 3; ++port) {
- if (esxVMX_ParseParallel(ctx, conf, port,
- &def->parallels[def->nparallels]) < 0) {
+ if (virVMXParseParallel(ctx, conf, port,
+ &def->parallels[def->nparallels]) < 0) {
goto cleanup;
}
@@ -1428,18 +1699,18 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
int
-esxVMX_ParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def)
+virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def)
{
bool enabled = false;
long long port = 0;
if (def == NULL || *def != NULL) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
- if (esxUtil_GetConfigBoolean(conf, "RemoteDisplay.vnc.enabled", &enabled,
- false, true) < 0) {
+ if (virVMXGetConfigBoolean(conf, "RemoteDisplay.vnc.enabled", &enabled,
+ false, true) < 0) {
return -1;
}
@@ -1454,14 +1725,14 @@ esxVMX_ParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def)
(*def)->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC;
- if (esxUtil_GetConfigLong(conf, "RemoteDisplay.vnc.port", &port, -1,
- true) < 0 ||
- esxUtil_GetConfigString(conf, "RemoteDisplay.vnc.ip",
- &(*def)->data.vnc.listenAddr, true) < 0 ||
- esxUtil_GetConfigString(conf, "RemoteDisplay.vnc.keymap",
- &(*def)->data.vnc.keymap, true) < 0 ||
- esxUtil_GetConfigString(conf, "RemoteDisplay.vnc.password",
- &(*def)->data.vnc.auth.passwd, true) < 0) {
+ if (virVMXGetConfigLong(conf, "RemoteDisplay.vnc.port", &port, -1,
+ true) < 0 ||
+ virVMXGetConfigString(conf, "RemoteDisplay.vnc.ip",
+ &(*def)->data.vnc.listenAddr, true) < 0 ||
+ virVMXGetConfigString(conf, "RemoteDisplay.vnc.keymap",
+ &(*def)->data.vnc.keymap, true) < 0 ||
+ virVMXGetConfigString(conf, "RemoteDisplay.vnc.password",
+ &(*def)->data.vnc.auth.passwd, true) < 0) {
goto failure;
}
@@ -1492,8 +1763,8 @@ esxVMX_ParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def)
int
-esxVMX_ParseSCSIController(virConfPtr conf, int controller, bool *present,
- int *virtualDev)
+virVMXParseSCSIController(virConfPtr conf, int controller, bool *present,
+ int *virtualDev)
{
char present_name[32];
char virtualDev_name[32];
@@ -1501,12 +1772,12 @@ esxVMX_ParseSCSIController(virConfPtr conf, int controller, bool *present,
char *tmp;
if (virtualDev == NULL || *virtualDev != -1) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (controller < 0 || controller > 3) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("SCSI controller index %d out of [0..3] range"),
controller);
return -1;
@@ -1516,8 +1787,7 @@ esxVMX_ParseSCSIController(virConfPtr conf, int controller, bool *present,
snprintf(virtualDev_name, sizeof(virtualDev_name), "scsi%d.virtualDev",
controller);
- if (esxUtil_GetConfigBoolean(conf, present_name, present, false,
- true) < 0) {
+ if (virVMXGetConfigBoolean(conf, present_name, present, false, true) < 0) {
goto failure;
}
@@ -1525,8 +1795,8 @@ esxVMX_ParseSCSIController(virConfPtr conf, int controller, bool *present,
return 0;
}
- if (esxUtil_GetConfigString(conf, virtualDev_name, &virtualDev_string,
- true) < 0) {
+ if (virVMXGetConfigString(conf, virtualDev_name, &virtualDev_string,
+ true) < 0) {
goto failure;
}
@@ -1537,14 +1807,14 @@ esxVMX_ParseSCSIController(virConfPtr conf, int controller, bool *present,
*tmp = c_tolower(*tmp);
}
- *virtualDev = esxVMX_SCSIControllerModelTypeFromString(virtualDev_string);
+ *virtualDev = virVMXSCSIControllerModelTypeFromString(virtualDev_string);
if (*virtualDev == -1 ||
(*virtualDev != VIR_DOMAIN_CONTROLLER_MODEL_BUSLOGIC &&
*virtualDev != VIR_DOMAIN_CONTROLLER_MODEL_LSILOGIC &&
*virtualDev != VIR_DOMAIN_CONTROLLER_MODEL_LSISAS1068 &&
*virtualDev != VIR_DOMAIN_CONTROLLER_MODEL_VMPVSCSI)) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry '%s' to be 'buslogic' or 'lsilogic' "
"or 'lsisas1068' or 'pvscsi' but found '%s'"),
virtualDev_name, virtualDev_string);
@@ -1578,9 +1848,9 @@ struct _virDomainDiskDef {
};*/
int
-esxVMX_ParseDisk(esxVMX_Context *ctx, virCapsPtr caps, virConfPtr conf,
- int device, int busType, int controllerOrBus, int unit,
- virDomainDiskDefPtr *def)
+virVMXParseDisk(virVMXContext *ctx, virCapsPtr caps, virConfPtr conf,
+ int device, int busType, int controllerOrBus, int unit,
+ virDomainDiskDefPtr *def)
{
/*
* device = {VIR_DOMAIN_DISK_DEVICE_DISK, VIR_DOMAIN_DISK_DEVICE_CDROM}
@@ -1624,7 +1894,7 @@ esxVMX_ParseDisk(esxVMX_Context *ctx, virCapsPtr caps, virConfPtr conf,
bool writeThrough = false;
if (def == NULL || *def != NULL) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
@@ -1641,14 +1911,14 @@ esxVMX_ParseDisk(esxVMX_Context *ctx, virCapsPtr caps, virConfPtr conf,
device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
if (busType == VIR_DOMAIN_DISK_BUS_SCSI) {
if (controllerOrBus < 0 || controllerOrBus > 3) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("SCSI controller index %d out of [0..3] range"),
controllerOrBus);
goto cleanup;
}
if (unit < 0 || unit > 15 || unit == 7) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("SCSI unit index %d out of [0..6,8..15] range"),
unit);
goto cleanup;
@@ -1668,14 +1938,14 @@ esxVMX_ParseDisk(esxVMX_Context *ctx, virCapsPtr caps, virConfPtr conf,
}
} else if (busType == VIR_DOMAIN_DISK_BUS_IDE) {
if (controllerOrBus < 0 || controllerOrBus > 1) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("IDE bus index %d out of [0..1] range"),
controllerOrBus);
goto cleanup;
}
if (unit < 0 || unit > 1) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("IDE unit index %d out of [0..1] range"), unit);
goto cleanup;
}
@@ -1691,7 +1961,7 @@ esxVMX_ParseDisk(esxVMX_Context *ctx, virCapsPtr caps, virConfPtr conf,
goto cleanup;
}
} else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Unsupported bus type '%s' for device type '%s'"),
virDomainDiskBusTypeToString(busType),
virDomainDiskDeviceTypeToString(device));
@@ -1700,14 +1970,14 @@ esxVMX_ParseDisk(esxVMX_Context *ctx, virCapsPtr caps, virConfPtr conf,
} else if (device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
if (busType == VIR_DOMAIN_DISK_BUS_FDC) {
if (controllerOrBus != 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("FDC controller index %d out of [0] range"),
controllerOrBus);
goto cleanup;
}
if (unit < 0 || unit > 1) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("FDC unit index %d out of [0..1] range"),
unit);
goto cleanup;
@@ -1724,36 +1994,35 @@ esxVMX_ParseDisk(esxVMX_Context *ctx, virCapsPtr caps, virConfPtr conf,
goto cleanup;
}
} else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Unsupported bus type '%s' for device type '%s'"),
virDomainDiskBusTypeToString(busType),
virDomainDiskDeviceTypeToString(device));
goto cleanup;
}
} else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Unsupported device type '%s'"),
virDomainDiskDeviceTypeToString(device));
goto cleanup;
}
- ESX_BUILD_VMX_NAME(present);
- ESX_BUILD_VMX_NAME(startConnected);
- ESX_BUILD_VMX_NAME(deviceType);
- ESX_BUILD_VMX_NAME(clientDevice);
- ESX_BUILD_VMX_NAME(fileType);
- ESX_BUILD_VMX_NAME(fileName);
- ESX_BUILD_VMX_NAME(writeThrough);
+ VMX_BUILD_NAME(present);
+ VMX_BUILD_NAME(startConnected);
+ VMX_BUILD_NAME(deviceType);
+ VMX_BUILD_NAME(clientDevice);
+ VMX_BUILD_NAME(fileType);
+ VMX_BUILD_NAME(fileName);
+ VMX_BUILD_NAME(writeThrough);
/* vmx:present */
- if (esxUtil_GetConfigBoolean(conf, present_name, &present, false,
- true) < 0) {
+ if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0) {
goto cleanup;
}
/* vmx:startConnected */
- if (esxUtil_GetConfigBoolean(conf, startConnected_name, &startConnected,
- true, true) < 0) {
+ if (virVMXGetConfigBoolean(conf, startConnected_name, &startConnected,
+ true, true) < 0) {
goto cleanup;
}
@@ -1763,13 +2032,13 @@ esxVMX_ParseDisk(esxVMX_Context *ctx, virCapsPtr caps, virConfPtr conf,
}
/* vmx:deviceType -> def:type */
- if (esxUtil_GetConfigString(conf, deviceType_name, &deviceType, true) < 0) {
+ if (virVMXGetConfigString(conf, deviceType_name, &deviceType, true) < 0) {
goto cleanup;
}
/* vmx:clientDevice */
- if (esxUtil_GetConfigBoolean(conf, clientDevice_name, &clientDevice, false,
- true) < 0) {
+ if (virVMXGetConfigBoolean(conf, clientDevice_name, &clientDevice, false,
+ true) < 0) {
goto cleanup;
}
@@ -1782,18 +2051,18 @@ esxVMX_ParseDisk(esxVMX_Context *ctx, virCapsPtr caps, virConfPtr conf,
}
/* vmx:fileType -> def:type */
- if (esxUtil_GetConfigString(conf, fileType_name, &fileType, true) < 0) {
+ if (virVMXGetConfigString(conf, fileType_name, &fileType, true) < 0) {
goto cleanup;
}
/* vmx:fileName -> def:src, def:type */
- if (esxUtil_GetConfigString(conf, fileName_name, &fileName, false) < 0) {
+ if (virVMXGetConfigString(conf, fileName_name, &fileName, false) < 0) {
goto cleanup;
}
/* vmx:writeThrough -> def:cachemode */
- if (esxUtil_GetConfigBoolean(conf, writeThrough_name, &writeThrough, false,
- true) < 0) {
+ if (virVMXGetConfigBoolean(conf, writeThrough_name, &writeThrough, false,
+ true) < 0) {
goto cleanup;
}
@@ -1804,7 +2073,7 @@ esxVMX_ParseDisk(esxVMX_Context *ctx, virCapsPtr caps, virConfPtr conf,
if (busType == VIR_DOMAIN_DISK_BUS_SCSI &&
STRCASENEQ(deviceType, "scsi-hardDisk") &&
STRCASENEQ(deviceType, "disk")) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry '%s' to be 'scsi-hardDisk' "
"or 'disk' but found '%s'"), deviceType_name,
deviceType);
@@ -1812,7 +2081,7 @@ esxVMX_ParseDisk(esxVMX_Context *ctx, virCapsPtr caps, virConfPtr conf,
} else if (busType == VIR_DOMAIN_DISK_BUS_IDE &&
STRCASENEQ(deviceType, "ata-hardDisk") &&
STRCASENEQ(deviceType, "disk")) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry '%s' to be 'ata-hardDisk' "
"or 'disk' but found '%s'"), deviceType_name,
deviceType);
@@ -1838,7 +2107,7 @@ esxVMX_ParseDisk(esxVMX_Context *ctx, virCapsPtr caps, virConfPtr conf,
*/
goto ignore;
} else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Invalid or not yet handled value '%s' for VMX entry "
"'%s'"), fileName, fileName_name);
goto cleanup;
@@ -1847,7 +2116,7 @@ esxVMX_ParseDisk(esxVMX_Context *ctx, virCapsPtr caps, virConfPtr conf,
if (virFileHasSuffix(fileName, ".iso")) {
if (deviceType != NULL) {
if (STRCASENEQ(deviceType, "cdrom-image")) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry '%s' to be 'cdrom-image' "
"but found '%s'"), deviceType_name, deviceType);
goto cleanup;
@@ -1874,7 +2143,7 @@ esxVMX_ParseDisk(esxVMX_Context *ctx, virCapsPtr caps, virConfPtr conf,
fileName = NULL;
} else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Invalid or not yet handled value '%s' for VMX entry "
"'%s'"), fileName, fileName_name);
goto cleanup;
@@ -1883,7 +2152,7 @@ esxVMX_ParseDisk(esxVMX_Context *ctx, virCapsPtr caps, virConfPtr conf,
if (virFileHasSuffix(fileName, ".flp")) {
if (fileType != NULL) {
if (STRCASENEQ(fileType, "file")) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry '%s' to be 'file' but "
"found '%s'"), fileType_name, fileType);
goto cleanup;
@@ -1902,19 +2171,19 @@ esxVMX_ParseDisk(esxVMX_Context *ctx, virCapsPtr caps, virConfPtr conf,
fileName = NULL;
} else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Invalid or not yet handled value '%s' for VMX entry "
"'%s'"), fileName, fileName_name);
goto cleanup;
}
} else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, _("Unsupported device type '%s'"),
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR, _("Unsupported device type '%s'"),
virDomainDiskDeviceTypeToString(device));
goto cleanup;
}
if (virDomainDiskDefAssignAddress(caps, *def) < 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Could not assign address to disk '%s'"), (*def)->src);
goto cleanup;
}
@@ -1946,7 +2215,7 @@ esxVMX_ParseDisk(esxVMX_Context *ctx, virCapsPtr caps, virConfPtr conf,
int
-esxVMX_ParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
+virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
{
int result = -1;
char prefix[48] = "";
@@ -1982,12 +2251,12 @@ esxVMX_ParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
char *networkName = NULL;
if (def == NULL || *def != NULL) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (controller < 0 || controller > 3) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Ethernet controller index %d out of [0..3] range"),
controller);
return -1;
@@ -2000,26 +2269,25 @@ esxVMX_ParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
snprintf(prefix, sizeof(prefix), "ethernet%d", controller);
- ESX_BUILD_VMX_NAME(present);
- ESX_BUILD_VMX_NAME(startConnected);
- ESX_BUILD_VMX_NAME(connectionType);
- ESX_BUILD_VMX_NAME(addressType);
- ESX_BUILD_VMX_NAME(generatedAddress);
- ESX_BUILD_VMX_NAME(address);
- ESX_BUILD_VMX_NAME(virtualDev);
- ESX_BUILD_VMX_NAME(features);
- ESX_BUILD_VMX_NAME(networkName);
- ESX_BUILD_VMX_NAME(vnet);
+ VMX_BUILD_NAME(present);
+ VMX_BUILD_NAME(startConnected);
+ VMX_BUILD_NAME(connectionType);
+ VMX_BUILD_NAME(addressType);
+ VMX_BUILD_NAME(generatedAddress);
+ VMX_BUILD_NAME(address);
+ VMX_BUILD_NAME(virtualDev);
+ VMX_BUILD_NAME(features);
+ VMX_BUILD_NAME(networkName);
+ VMX_BUILD_NAME(vnet);
/* vmx:present */
- if (esxUtil_GetConfigBoolean(conf, present_name, &present, false,
- true) < 0) {
+ if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0) {
goto cleanup;
}
/* vmx:startConnected */
- if (esxUtil_GetConfigBoolean(conf, startConnected_name, &startConnected,
- true, true) < 0) {
+ if (virVMXGetConfigBoolean(conf, startConnected_name, &startConnected,
+ true, true) < 0) {
goto cleanup;
}
@@ -2029,17 +2297,17 @@ esxVMX_ParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
}
/* vmx:connectionType -> def:type */
- if (esxUtil_GetConfigString(conf, connectionType_name, &connectionType,
- true) < 0) {
+ if (virVMXGetConfigString(conf, connectionType_name, &connectionType,
+ true) < 0) {
goto cleanup;
}
/* vmx:addressType, vmx:generatedAddress, vmx:address -> def:mac */
- if (esxUtil_GetConfigString(conf, addressType_name, &addressType,
- true) < 0 ||
- esxUtil_GetConfigString(conf, generatedAddress_name, &generatedAddress,
- true) < 0 ||
- esxUtil_GetConfigString(conf, address_name, &address, true) < 0) {
+ if (virVMXGetConfigString(conf, addressType_name, &addressType,
+ true) < 0 ||
+ virVMXGetConfigString(conf, generatedAddress_name, &generatedAddress,
+ true) < 0 ||
+ virVMXGetConfigString(conf, address_name, &address, true) < 0) {
goto cleanup;
}
@@ -2047,7 +2315,7 @@ esxVMX_ParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
STRCASEEQ(addressType, "vpx")) {
if (generatedAddress != NULL) {
if (virParseMacAddr(generatedAddress, (*def)->mac) < 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry '%s' to be MAC address but "
"found '%s'"), generatedAddress_name,
generatedAddress);
@@ -2057,22 +2325,22 @@ esxVMX_ParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
} else if (STRCASEEQ(addressType, "static")) {
if (address != NULL) {
if (virParseMacAddr(address, (*def)->mac) < 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry '%s' to be MAC address but "
"found '%s'"), address_name, address);
goto cleanup;
}
}
} else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry '%s' to be 'generated' or 'static' or "
"'vpx' but found '%s'"), addressType_name, addressType);
goto cleanup;
}
/* vmx:virtualDev, vmx:features -> def:model */
- if (esxUtil_GetConfigString(conf, virtualDev_name, &virtualDev, true) < 0 ||
- esxUtil_GetConfigLong(conf, features_name, &features, 0, true) < 0) {
+ if (virVMXGetConfigString(conf, virtualDev_name, &virtualDev, true) < 0 ||
+ virVMXGetConfigLong(conf, features_name, &features, 0, true) < 0) {
goto cleanup;
}
@@ -2081,7 +2349,7 @@ esxVMX_ParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
STRCASENEQ(virtualDev, "vmxnet") &&
STRCASENEQ(virtualDev, "vmxnet3") &&
STRCASENEQ(virtualDev, "e1000")) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry '%s' to be 'vlance' or 'vmxnet' or "
"'vmxnet3' or 'e1000' but found '%s'"), virtualDev_name,
virtualDev);
@@ -2104,14 +2372,14 @@ esxVMX_ParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
if ((connectionType == NULL ||
STRCASEEQ(connectionType, "bridged") ||
STRCASEEQ(connectionType, "custom")) &&
- esxUtil_GetConfigString(conf, networkName_name, &networkName,
- false) < 0) {
+ virVMXGetConfigString(conf, networkName_name, &networkName,
+ false) < 0) {
goto cleanup;
}
/* vmx:vnet -> def:data.ifname */
if (connectionType != NULL && STRCASEEQ(connectionType, "custom") &&
- esxUtil_GetConfigString(conf, vnet_name, &vnet, false) < 0) {
+ virVMXGetConfigString(conf, vnet_name, &vnet, false) < 0) {
goto cleanup;
}
@@ -2125,13 +2393,13 @@ esxVMX_ParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
networkName = NULL;
} else if (STRCASEEQ(connectionType, "hostonly")) {
/* FIXME */
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("No yet handled value '%s' for VMX entry '%s'"),
connectionType, connectionType_name);
goto cleanup;
} else if (STRCASEEQ(connectionType, "nat")) {
/* FIXME */
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("No yet handled value '%s' for VMX entry '%s'"),
connectionType, connectionType_name);
goto cleanup;
@@ -2145,7 +2413,7 @@ esxVMX_ParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
networkName = NULL;
vnet = NULL;
} else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Invalid value '%s' for VMX entry '%s'"), connectionType,
connectionType_name);
goto cleanup;
@@ -2180,8 +2448,8 @@ esxVMX_ParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
int
-esxVMX_ParseSerial(esxVMX_Context *ctx, virConfPtr conf, int port,
- virDomainChrDefPtr *def)
+virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
+ virDomainChrDefPtr *def)
{
int result = -1;
char prefix[48] = "";
@@ -2204,12 +2472,12 @@ esxVMX_ParseSerial(esxVMX_Context *ctx, virConfPtr conf, int port,
xmlURIPtr parsedUri = NULL;
if (def == NULL || *def != NULL) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (port < 0 || port > 3) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Serial port index %d out of [0..3] range"), port);
return -1;
}
@@ -2223,21 +2491,20 @@ esxVMX_ParseSerial(esxVMX_Context *ctx, virConfPtr conf, int port,
snprintf(prefix, sizeof(prefix), "serial%d", port);
- ESX_BUILD_VMX_NAME(present);
- ESX_BUILD_VMX_NAME(startConnected);
- ESX_BUILD_VMX_NAME(fileType);
- ESX_BUILD_VMX_NAME(fileName);
- ESX_BUILD_VMX_NAME_EXTRA(network_endPoint, "network.endPoint");
+ VMX_BUILD_NAME(present);
+ VMX_BUILD_NAME(startConnected);
+ VMX_BUILD_NAME(fileType);
+ VMX_BUILD_NAME(fileName);
+ VMX_BUILD_NAME_EXTRA(network_endPoint, "network.endPoint");
/* vmx:present */
- if (esxUtil_GetConfigBoolean(conf, present_name, &present, false,
- true) < 0) {
+ if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0) {
goto cleanup;
}
/* vmx:startConnected */
- if (esxUtil_GetConfigBoolean(conf, startConnected_name, &startConnected,
- true, true) < 0) {
+ if (virVMXGetConfigBoolean(conf, startConnected_name, &startConnected,
+ true, true) < 0) {
goto cleanup;
}
@@ -2247,18 +2514,18 @@ esxVMX_ParseSerial(esxVMX_Context *ctx, virConfPtr conf, int port,
}
/* vmx:fileType -> def:type */
- if (esxUtil_GetConfigString(conf, fileType_name, &fileType, false) < 0) {
+ if (virVMXGetConfigString(conf, fileType_name, &fileType, false) < 0) {
goto cleanup;
}
/* vmx:fileName -> def:data.file.path */
- if (esxUtil_GetConfigString(conf, fileName_name, &fileName, false) < 0) {
+ if (virVMXGetConfigString(conf, fileName_name, &fileName, false) < 0) {
goto cleanup;
}
/* vmx:network.endPoint -> def:data.tcp.listen */
- if (esxUtil_GetConfigString(conf, network_endPoint_name, &network_endPoint,
- true) < 0) {
+ if (virVMXGetConfigString(conf, network_endPoint_name, &network_endPoint,
+ true) < 0) {
goto cleanup;
}
@@ -2299,7 +2566,7 @@ esxVMX_ParseSerial(esxVMX_Context *ctx, virConfPtr conf, int port,
}
if (parsedUri->port == 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("VMX entry '%s' doesn't contain a port part"),
fileName_name);
goto cleanup;
@@ -2333,7 +2600,7 @@ esxVMX_ParseSerial(esxVMX_Context *ctx, virConfPtr conf, int port,
STRCASEEQ(parsedUri->scheme, "tcp6+ssl")) {
(*def)->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_TLS;
} else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("VMX entry '%s' contains unsupported scheme '%s'"),
fileName_name, parsedUri->scheme);
goto cleanup;
@@ -2344,13 +2611,13 @@ esxVMX_ParseSerial(esxVMX_Context *ctx, virConfPtr conf, int port,
} else if (STRCASEEQ(network_endPoint, "client")) {
(*def)->data.tcp.listen = 0;
} else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry '%s' to be 'server' or 'client' "
"but found '%s'"), network_endPoint_name, network_endPoint);
goto cleanup;
}
} else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry '%s' to be 'device', 'file' or 'pipe' "
"or 'network' but found '%s'"), fileType_name, fileType);
goto cleanup;
@@ -2383,8 +2650,8 @@ esxVMX_ParseSerial(esxVMX_Context *ctx, virConfPtr conf, int port,
int
-esxVMX_ParseParallel(esxVMX_Context *ctx, virConfPtr conf, int port,
- virDomainChrDefPtr *def)
+virVMXParseParallel(virVMXContext *ctx, virConfPtr conf, int port,
+ virDomainChrDefPtr *def)
{
int result = -1;
char prefix[48] = "";
@@ -2402,12 +2669,12 @@ esxVMX_ParseParallel(esxVMX_Context *ctx, virConfPtr conf, int port,
char *fileName = NULL;
if (def == NULL || *def != NULL) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (port < 0 || port > 2) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Parallel port index %d out of [0..2] range"), port);
return -1;
}
@@ -2421,20 +2688,19 @@ esxVMX_ParseParallel(esxVMX_Context *ctx, virConfPtr conf, int port,
snprintf(prefix, sizeof(prefix), "parallel%d", port);
- ESX_BUILD_VMX_NAME(present);
- ESX_BUILD_VMX_NAME(startConnected);
- ESX_BUILD_VMX_NAME(fileType);
- ESX_BUILD_VMX_NAME(fileName);
+ VMX_BUILD_NAME(present);
+ VMX_BUILD_NAME(startConnected);
+ VMX_BUILD_NAME(fileType);
+ VMX_BUILD_NAME(fileName);
/* vmx:present */
- if (esxUtil_GetConfigBoolean(conf, present_name, &present, false,
- true) < 0) {
+ if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0) {
goto cleanup;
}
/* vmx:startConnected */
- if (esxUtil_GetConfigBoolean(conf, startConnected_name, &startConnected,
- true, true) < 0) {
+ if (virVMXGetConfigBoolean(conf, startConnected_name, &startConnected,
+ true, true) < 0) {
goto cleanup;
}
@@ -2444,12 +2710,12 @@ esxVMX_ParseParallel(esxVMX_Context *ctx, virConfPtr conf, int port,
}
/* vmx:fileType -> def:type */
- if (esxUtil_GetConfigString(conf, fileType_name, &fileType, false) < 0) {
+ if (virVMXGetConfigString(conf, fileType_name, &fileType, false) < 0) {
goto cleanup;
}
/* vmx:fileName -> def:data.file.path */
- if (esxUtil_GetConfigString(conf, fileName_name, &fileName, false) < 0) {
+ if (virVMXGetConfigString(conf, fileName_name, &fileName, false) < 0) {
goto cleanup;
}
@@ -2469,7 +2735,7 @@ esxVMX_ParseParallel(esxVMX_Context *ctx, virConfPtr conf, int port,
goto cleanup;
}
} else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry '%s' to be 'device' or 'file' but "
"found '%s'"), fileType_name, fileType);
goto cleanup;
@@ -2504,8 +2770,8 @@ esxVMX_ParseParallel(esxVMX_Context *ctx, virConfPtr conf, int port,
*/
char *
-esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
- esxVI_ProductVersion productVersion)
+virVMXFormatConfig(virVMXContext *ctx, virCapsPtr caps, virDomainDefPtr def,
+ int virtualHW_version)
{
char *vmx = NULL;
int i;
@@ -2520,15 +2786,15 @@ esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
bool floppy_present[2] = { false, false };
if (ctx->formatFileName == NULL) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
- _("esxVMX_Context has no formatFileName function set"));
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("virVMXContext has no formatFileName function set"));
return NULL;
}
memset(zero, 0, VIR_UUID_BUFLEN);
- if (def->virtType != VIR_DOMAIN_VIRT_VMWARE) { /* FIXME: maybe add VIR_DOMAIN_VIRT_ESX ? */
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ if (def->virtType != VIR_DOMAIN_VIRT_VMWARE) {
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting virt type to be '%s' but found '%s'"),
virDomainVirtTypeToString(VIR_DOMAIN_VIRT_VMWARE),
virDomainVirtTypeToString(def->virtType));
@@ -2542,27 +2808,8 @@ esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
virBufferAddLit(&buffer, "config.version = \"8\"\n");
/* vmx:virtualHW.version */
- switch (productVersion) {
- case esxVI_ProductVersion_ESX35:
- virBufferAddLit(&buffer, "virtualHW.version = \"4\"\n");
- break;
-
- case esxVI_ProductVersion_GSX20:
- case esxVI_ProductVersion_ESX40:
- case esxVI_ProductVersion_ESX41:
- case esxVI_ProductVersion_ESX4x:
- /* FIXME: Putting VPX* here is a hack until a more fine grained system is in place */
- case esxVI_ProductVersion_VPX40:
- case esxVI_ProductVersion_VPX41:
- case esxVI_ProductVersion_VPX4x:
- virBufferAddLit(&buffer, "virtualHW.version = \"7\"\n");
- break;
-
- default:
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Unexpected product version"));
- goto cleanup;
- }
+ virBufferVSprintf(&buffer, "virtualHW.version = \"%d\"\n",
+ virtualHW_version);
/* def:os.arch -> vmx:guestOS */
if (def->os.arch == NULL || STRCASEEQ(def->os.arch, "i686")) {
@@ -2570,7 +2817,7 @@ esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
} else if (STRCASEEQ(def->os.arch, "x86_64")) {
virBufferAddLit(&buffer, "guestOS = \"other-64\"\n");
} else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting domain XML attribute 'arch' of entry 'os/type' "
"to be 'i686' or 'x86_64' but found '%s'"), def->os.arch);
goto cleanup;
@@ -2583,7 +2830,7 @@ esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
} else if (def->os.smbios_mode == VIR_DOMAIN_SMBIOS_HOST) {
virBufferAddLit(&buffer, "smbios.reflecthost = \"true\"\n");
} else {
- ESX_ERROR(VIR_ERR_CONFIG_UNSUPPORTED,
+ VMX_ERROR(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported SMBIOS mode '%s'"),
virDomainSmbiosModeTypeToString(def->os.smbios_mode));
goto cleanup;
@@ -2603,13 +2850,13 @@ esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
}
/* def:name -> vmx:displayName */
- preliminaryDisplayName = esxUtil_EscapeHexPipe(def->name);
+ preliminaryDisplayName = virVMXEscapeHexPipe(def->name);
if (preliminaryDisplayName == NULL) {
goto cleanup;
}
- displayName = esxUtil_EscapeHexPercent(preliminaryDisplayName);
+ displayName = virVMXEscapeHexPercent(preliminaryDisplayName);
if (displayName == NULL) {
goto cleanup;
@@ -2619,14 +2866,14 @@ esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
/* def:description -> vmx:annotation */
if (def->description != NULL) {
- annotation = esxUtil_EscapeHexPipe(def->description);
+ annotation = virVMXEscapeHexPipe(def->description);
virBufferVSprintf(&buffer, "annotation = \"%s\"\n", annotation);
}
/* def:mem.max_balloon -> vmx:memsize */
if (def->mem.max_balloon <= 0 || def->mem.max_balloon % 4096 != 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting domain XML entry 'memory' to be an unsigned "
"integer (multiple of 4096) but found %lld"),
(unsigned long long)def->mem.max_balloon);
@@ -2640,7 +2887,7 @@ esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
/* def:mem.cur_balloon -> vmx:sched.mem.max */
if (def->mem.cur_balloon < def->mem.max_balloon) {
if (def->mem.cur_balloon <= 0 || def->mem.cur_balloon % 1024 != 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting domain XML entry 'currentMemory' to be an "
"unsigned integer (multiple of 1024) but found %llu"),
(unsigned long long)def->mem.cur_balloon);
@@ -2655,7 +2902,7 @@ esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
/* def:mem.min_guarantee -> vmx:sched.mem.minsize */
if (def->mem.min_guarantee > 0) {
if (def->mem.min_guarantee % 1024 != 0) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting domain XML entry 'memtune/min_guarantee' to "
"be an unsigned integer (multiple of 1024) but found %llu"),
(unsigned long long)def->mem.min_guarantee);
@@ -2669,13 +2916,13 @@ esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
/* def:maxvcpus -> vmx:numvcpus */
if (def->vcpus != def->maxvcpus) {
- ESX_ERROR(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ VMX_ERROR(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("No support for domain XML entry 'vcpu' attribute "
"'current'"));
goto cleanup;
}
if (def->maxvcpus <= 0 || (def->maxvcpus % 2 != 0 && def->maxvcpus != 1)) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting domain XML entry 'vcpu' to be an unsigned "
"integer (1 or a multiple of 2) but found %d"),
def->maxvcpus);
@@ -2697,7 +2944,7 @@ esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
}
if (sched_cpu_affinity_length < def->maxvcpus) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting domain XML attribute 'cpuset' of entry "
"'vcpu' to contain at least %d CPU(s)"),
def->maxvcpus);
@@ -2723,14 +2970,14 @@ esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
for (i = 0; i < def->ngraphics; ++i) {
switch (def->graphics[i]->type) {
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
- if (esxVMX_FormatVNC(def->graphics[i], &buffer) < 0) {
+ if (virVMXFormatVNC(def->graphics[i], &buffer) < 0) {
goto cleanup;
}
break;
default:
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Unsupported graphics type '%s'"),
virDomainGraphicsTypeToString(def->graphics[i]->type));
goto cleanup;
@@ -2739,14 +2986,14 @@ esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
/* def:disks */
for (i = 0; i < def->ndisks; ++i) {
- if (esxVMX_VerifyDiskAddress(caps, def->disks[i]) < 0 ||
- esxVMX_HandleLegacySCSIDiskDriverName(def, def->disks[i]) < 0) {
+ if (virVMXVerifyDiskAddress(caps, def->disks[i]) < 0 ||
+ virVMXHandleLegacySCSIDiskDriverName(def, def->disks[i]) < 0) {
goto cleanup;
}
}
- if (esxVMX_GatherSCSIControllers(ctx, def, scsi_virtualDev,
- scsi_present) < 0) {
+ if (virVMXGatherSCSIControllers(ctx, def, scsi_virtualDev,
+ scsi_present) < 0) {
goto cleanup;
}
@@ -2756,7 +3003,7 @@ esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
if (scsi_virtualDev[i] != -1) {
virBufferVSprintf(&buffer, "scsi%d.virtualDev = \"%s\"\n", i,
- esxVMX_SCSIControllerModelTypeToString
+ virVMXSCSIControllerModelTypeToString
(scsi_virtualDev[i]));
}
}
@@ -2765,29 +3012,29 @@ esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
for (i = 0; i < def->ndisks; ++i) {
switch (def->disks[i]->device) {
case VIR_DOMAIN_DISK_DEVICE_DISK:
- if (esxVMX_FormatHardDisk(ctx, def->disks[i], &buffer) < 0) {
+ if (virVMXFormatHardDisk(ctx, def->disks[i], &buffer) < 0) {
goto cleanup;
}
break;
case VIR_DOMAIN_DISK_DEVICE_CDROM:
- if (esxVMX_FormatCDROM(ctx, def->disks[i], &buffer) < 0) {
+ if (virVMXFormatCDROM(ctx, def->disks[i], &buffer) < 0) {
goto cleanup;
}
break;
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
- if (esxVMX_FormatFloppy(ctx, def->disks[i], &buffer,
- floppy_present) < 0) {
+ if (virVMXFormatFloppy(ctx, def->disks[i], &buffer,
+ floppy_present) < 0) {
goto cleanup;
}
break;
default:
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Unsupported disk device type '%s'"),
virDomainDiskDeviceTypeToString(def->disks[i]->device));
goto cleanup;
@@ -2806,7 +3053,7 @@ esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
/* def:nets */
for (i = 0; i < def->nnets; ++i) {
- if (esxVMX_FormatEthernet(def->nets[i], i, &buffer) < 0) {
+ if (virVMXFormatEthernet(def->nets[i], i, &buffer) < 0) {
goto cleanup;
}
}
@@ -2822,14 +3069,14 @@ esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
/* def:serials */
for (i = 0; i < def->nserials; ++i) {
- if (esxVMX_FormatSerial(ctx, def->serials[i], &buffer) < 0) {
+ if (virVMXFormatSerial(ctx, def->serials[i], &buffer) < 0) {
goto cleanup;
}
}
/* def:parallels */
for (i = 0; i < def->nparallels; ++i) {
- if (esxVMX_FormatParallel(ctx, def->parallels[i], &buffer) < 0) {
+ if (virVMXFormatParallel(ctx, def->parallels[i], &buffer) < 0) {
goto cleanup;
}
}
@@ -2857,10 +3104,10 @@ esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
int
-esxVMX_FormatVNC(virDomainGraphicsDefPtr def, virBufferPtr buffer)
+virVMXFormatVNC(virDomainGraphicsDefPtr def, virBufferPtr buffer)
{
if (def->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
@@ -2900,8 +3147,8 @@ esxVMX_FormatVNC(virDomainGraphicsDefPtr def, virBufferPtr buffer)
int
-esxVMX_FormatHardDisk(esxVMX_Context *ctx, virDomainDiskDefPtr def,
- virBufferPtr buffer)
+virVMXFormatHardDisk(virVMXContext *ctx, virDomainDiskDefPtr def,
+ virBufferPtr buffer)
{
int controllerOrBus, unit;
const char *busName = NULL;
@@ -2910,7 +3157,7 @@ esxVMX_FormatHardDisk(esxVMX_Context *ctx, virDomainDiskDefPtr def,
char *fileName = NULL;
if (def->device != VIR_DOMAIN_DISK_DEVICE_DISK) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
@@ -2919,8 +3166,8 @@ esxVMX_FormatHardDisk(esxVMX_Context *ctx, virDomainDiskDefPtr def,
entryPrefix = "scsi";
deviceTypePrefix = "scsi";
- if (esxVMX_SCSIDiskNameToControllerAndUnit(def->dst, &controllerOrBus,
- &unit) < 0) {
+ if (virVMXSCSIDiskNameToControllerAndUnit(def->dst, &controllerOrBus,
+ &unit) < 0) {
return -1;
}
} else if (def->bus == VIR_DOMAIN_DISK_BUS_IDE) {
@@ -2928,19 +3175,19 @@ esxVMX_FormatHardDisk(esxVMX_Context *ctx, virDomainDiskDefPtr def,
entryPrefix = "ide";
deviceTypePrefix = "ata";
- if (esxVMX_IDEDiskNameToBusAndUnit(def->dst, &controllerOrBus,
+ if (virVMXIDEDiskNameToBusAndUnit(def->dst, &controllerOrBus,
&unit) < 0) {
return -1;
}
} else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Unsupported bus type '%s' for harddisk"),
virDomainDiskBusTypeToString(def->bus));
return -1;
}
if (def->type != VIR_DOMAIN_DISK_TYPE_FILE) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("%s harddisk '%s' has unsupported type '%s', expecting '%s'"),
busName, def->dst, virDomainDiskTypeToString(def->type),
virDomainDiskTypeToString(VIR_DOMAIN_DISK_TYPE_FILE));
@@ -2954,7 +3201,7 @@ esxVMX_FormatHardDisk(esxVMX_Context *ctx, virDomainDiskDefPtr def,
if (def->src != NULL) {
if (! virFileHasSuffix(def->src, ".vmdk")) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Image file for %s harddisk '%s' has unsupported suffix, "
"expecting '.vmdk'"), busName, def->dst);
return -1;
@@ -2977,7 +3224,7 @@ esxVMX_FormatHardDisk(esxVMX_Context *ctx, virDomainDiskDefPtr def,
virBufferVSprintf(buffer, "%s%d:%d.writeThrough = \"true\"\n",
entryPrefix, controllerOrBus, unit);
} else if (def->cachemode != VIR_DOMAIN_DISK_CACHE_DEFAULT) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("%s harddisk '%s' has unsupported cache mode '%s'"),
busName, def->dst,
virDomainDiskCacheTypeToString(def->cachemode));
@@ -2991,8 +3238,8 @@ esxVMX_FormatHardDisk(esxVMX_Context *ctx, virDomainDiskDefPtr def,
int
-esxVMX_FormatCDROM(esxVMX_Context *ctx, virDomainDiskDefPtr def,
- virBufferPtr buffer)
+virVMXFormatCDROM(virVMXContext *ctx, virDomainDiskDefPtr def,
+ virBufferPtr buffer)
{
int controllerOrBus, unit;
const char *busName = NULL;
@@ -3000,7 +3247,7 @@ esxVMX_FormatCDROM(esxVMX_Context *ctx, virDomainDiskDefPtr def,
char *fileName = NULL;
if (def->device != VIR_DOMAIN_DISK_DEVICE_CDROM) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
@@ -3008,20 +3255,20 @@ esxVMX_FormatCDROM(esxVMX_Context *ctx, virDomainDiskDefPtr def,
busName = "SCSI";
entryPrefix = "scsi";
- if (esxVMX_SCSIDiskNameToControllerAndUnit(def->dst, &controllerOrBus,
- &unit) < 0) {
+ if (virVMXSCSIDiskNameToControllerAndUnit(def->dst, &controllerOrBus,
+ &unit) < 0) {
return -1;
}
} else if (def->bus == VIR_DOMAIN_DISK_BUS_IDE) {
busName = "IDE";
entryPrefix = "ide";
- if (esxVMX_IDEDiskNameToBusAndUnit(def->dst, &controllerOrBus,
- &unit) < 0) {
+ if (virVMXIDEDiskNameToBusAndUnit(def->dst, &controllerOrBus,
+ &unit) < 0) {
return -1;
}
} else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Unsupported bus type '%s' for cdrom"),
virDomainDiskBusTypeToString(def->bus));
return -1;
@@ -3036,7 +3283,7 @@ esxVMX_FormatCDROM(esxVMX_Context *ctx, virDomainDiskDefPtr def,
if (def->src != NULL) {
if (! virFileHasSuffix(def->src, ".iso")) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Image file for %s cdrom '%s' has unsupported "
"suffix, expecting '.iso'"), busName, def->dst);
return -1;
@@ -3062,7 +3309,7 @@ esxVMX_FormatCDROM(esxVMX_Context *ctx, virDomainDiskDefPtr def,
entryPrefix, controllerOrBus, unit, def->src);
}
} else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("%s cdrom '%s' has unsupported type '%s', expecting '%s' "
"or '%s'"), busName, def->dst,
virDomainDiskTypeToString(def->type),
@@ -3077,18 +3324,18 @@ esxVMX_FormatCDROM(esxVMX_Context *ctx, virDomainDiskDefPtr def,
int
-esxVMX_FormatFloppy(esxVMX_Context *ctx, virDomainDiskDefPtr def,
- virBufferPtr buffer, bool floppy_present[2])
+virVMXFormatFloppy(virVMXContext *ctx, virDomainDiskDefPtr def,
+ virBufferPtr buffer, bool floppy_present[2])
{
int unit;
char *fileName = NULL;
if (def->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
- if (esxVMX_FloppyDiskNameToUnit(def->dst, &unit) < 0) {
+ if (virVMXFloppyDiskNameToUnit(def->dst, &unit) < 0) {
return -1;
}
@@ -3101,7 +3348,7 @@ esxVMX_FormatFloppy(esxVMX_Context *ctx, virDomainDiskDefPtr def,
if (def->src != NULL) {
if (! virFileHasSuffix(def->src, ".flp")) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Image file for floppy '%s' has unsupported "
"suffix, expecting '.flp'"), def->dst);
return -1;
@@ -3126,7 +3373,7 @@ esxVMX_FormatFloppy(esxVMX_Context *ctx, virDomainDiskDefPtr def,
unit, def->src);
}
} else {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Floppy '%s' has unsupported type '%s', expecting '%s' "
"or '%s'"), def->dst,
virDomainDiskTypeToString(def->type),
@@ -3141,14 +3388,14 @@ esxVMX_FormatFloppy(esxVMX_Context *ctx, virDomainDiskDefPtr def,
int
-esxVMX_FormatEthernet(virDomainNetDefPtr def, int controller,
- virBufferPtr buffer)
+virVMXFormatEthernet(virDomainNetDefPtr def, int controller,
+ virBufferPtr buffer)
{
char mac_string[VIR_MAC_STRING_BUFLEN];
unsigned int prefix, suffix;
if (controller < 0 || controller > 3) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Ethernet controller index %d out of [0..3] range"),
controller);
return -1;
@@ -3163,7 +3410,7 @@ esxVMX_FormatEthernet(virDomainNetDefPtr def, int controller,
STRCASENEQ(def->model, "vmxnet2") &&
STRCASENEQ(def->model, "vmxnet3") &&
STRCASENEQ(def->model, "e1000")) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting domain XML entry 'devices/interfase/model' "
"to be 'vlance' or 'vmxnet' or 'vmxnet2' or 'vmxnet3' "
"or 'e1000' but found '%s'"), def->model);
@@ -3200,7 +3447,7 @@ esxVMX_FormatEthernet(virDomainNetDefPtr def, int controller,
break;
default:
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, _("Unsupported net type '%s'"),
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR, _("Unsupported net type '%s'"),
virDomainNetTypeToString(def->type));
return -1;
}
@@ -3243,14 +3490,14 @@ esxVMX_FormatEthernet(virDomainNetDefPtr def, int controller,
int
-esxVMX_FormatSerial(esxVMX_Context *ctx, virDomainChrDefPtr def,
- virBufferPtr buffer)
+virVMXFormatSerial(virVMXContext *ctx, virDomainChrDefPtr def,
+ virBufferPtr buffer)
{
char *fileName = NULL;
const char *protocol;
if (def->target.port < 0 || def->target.port > 3) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Serial port index %d out of [0..3] range"),
def->target.port);
return -1;
@@ -3315,7 +3562,7 @@ esxVMX_FormatSerial(esxVMX_Context *ctx, virDomainChrDefPtr def,
break;
default:
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Unsupported character device TCP protocol '%s'"),
virDomainChrTcpProtocolTypeToString(def->data.tcp.protocol));
return -1;
@@ -3332,7 +3579,7 @@ esxVMX_FormatSerial(esxVMX_Context *ctx, virDomainChrDefPtr def,
break;
default:
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Unsupported character device type '%s'"),
virDomainChrTypeToString(def->type));
return -1;
@@ -3349,13 +3596,13 @@ esxVMX_FormatSerial(esxVMX_Context *ctx, virDomainChrDefPtr def,
int
-esxVMX_FormatParallel(esxVMX_Context *ctx, virDomainChrDefPtr def,
- virBufferPtr buffer)
+virVMXFormatParallel(virVMXContext *ctx, virDomainChrDefPtr def,
+ virBufferPtr buffer)
{
char *fileName = NULL;
if (def->target.port < 0 || def->target.port > 2) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Parallel port index %d out of [0..2] range"),
def->target.port);
return -1;
@@ -3390,7 +3637,7 @@ esxVMX_FormatParallel(esxVMX_Context *ctx, virDomainChrDefPtr def,
break;
default:
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Unsupported character device type '%s'"),
virDomainChrTypeToString(def->type));
return -1;
diff --git a/src/vmx/vmx.h b/src/vmx/vmx.h
new file mode 100644
index 0000000..1a4fd9c
--- /dev/null
+++ b/src/vmx/vmx.h
@@ -0,0 +1,132 @@
+
+/*
+ * vmx.h: VMware VMX parsing/formatting functions
+ *
+ * Copyright (C) 2009-2010 Matthias Bolte <matthias.bolte(a)googlemail.com>
+ *
+ * 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
+ *
+ */
+
+#ifndef __VIR_VMX_H__
+# define __VIR_VMX_H__
+
+# include <stdbool.h>
+
+# include "internal.h"
+# include "conf.h"
+# include "domain_conf.h"
+
+typedef struct _virVMXContext virVMXContext;
+
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Context
+ */
+
+typedef char * (*virVMXParseFileName)(const char *fileName, void *opaque);
+typedef char * (*virVMXFormatFileName)(const char *src, void *opaque);
+typedef int (*virVMXAutodetectSCSIControllerModel)(virDomainDiskDefPtr def,
+ int *model, void *opaque);
+
+/*
+ * virVMXParseFileName is only used by virVMXParseConfig.
+ * virVMXFormatFileName is only used by virVMXFormatConfig.
+ * virVMXAutodetectSCSIControllerModel is optionally used by virVMXFormatConfig.
+ */
+struct _virVMXContext {
+ void *opaque;
+ virVMXParseFileName parseFileName;
+ virVMXFormatFileName formatFileName;
+ virVMXAutodetectSCSIControllerModel autodetectSCSIControllerModel;
+};
+
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Helpers
+ */
+
+char *virVMXEscapeHex(const char *string, char escape, const char *special);
+
+# define virVMXEscapeHexPipe(_string) virVMXEscapeHex(_string, '|', "\"")
+
+# define virVMXEscapeHexPercent(_string) virVMXEscapeHex(_string, '%', "/\\")
+
+int virVMXUnescapeHex(char *string, char escape);
+
+# define virVMXUnescapeHexPipe(_string) virVMXUnescapeHex(_string, '|')
+
+# define virVMXUnescapeHexPercent(_string) virVMXUnescapeHex(_string, '%')
+
+char *virVMXConvertToUTF8(const char *encoding, const char *string);
+
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * VMX -> Domain XML
+ */
+
+virDomainDefPtr virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps,
+ const char *vmx);
+
+int virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def);
+
+int virVMXParseSCSIController(virConfPtr conf, int controller, bool *present,
+ int *virtualDev);
+
+int virVMXParseDisk(virVMXContext *ctx, virCapsPtr caps, virConfPtr conf,
+ int device, int busType, int controllerOrBus, int unit,
+ virDomainDiskDefPtr *def);
+
+int virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def);
+
+int virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
+ virDomainChrDefPtr *def);
+
+int virVMXParseParallel(virVMXContext *ctx, virConfPtr conf, int port,
+ virDomainChrDefPtr *def);
+
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Domain XML -> VMX
+ */
+
+char *virVMXFormatConfig(virVMXContext *ctx, virCapsPtr caps,
+ virDomainDefPtr def, int virtualHW_version);
+
+int virVMXFormatVNC(virDomainGraphicsDefPtr def, virBufferPtr buffer);
+
+int virVMXFormatHardDisk(virVMXContext *ctx, virDomainDiskDefPtr def,
+ virBufferPtr buffer);
+
+int virVMXFormatCDROM(virVMXContext *ctx, virDomainDiskDefPtr def,
+ virBufferPtr buffer);
+
+int virVMXFormatFloppy(virVMXContext *ctx, virDomainDiskDefPtr def,
+ virBufferPtr buffer, bool floppy_present[2]);
+
+int virVMXFormatEthernet(virDomainNetDefPtr def, int controller,
+ virBufferPtr buffer);
+
+int virVMXFormatSerial(virVMXContext *ctx, virDomainChrDefPtr def,
+ virBufferPtr buffer);
+
+int virVMXFormatParallel(virVMXContext *ctx, virDomainChrDefPtr def,
+ virBufferPtr buffer);
+
+#endif /* __VIR_VMX_H__ */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 69731d3..697b401 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -91,7 +91,11 @@ check_PROGRAMS += qemuxml2argvtest qemuxml2xmltest qemuargv2xmltest qemuhelptest
endif
if WITH_ESX
-check_PROGRAMS += esxutilstest vmx2xmltest xml2vmxtest
+check_PROGRAMS += esxutilstest
+endif
+
+if WITH_VMX
+check_PROGRAMS += vmx2xmltest xml2vmxtest
endif
if WITH_SECDRIVER_SELINUX
@@ -180,7 +184,11 @@ TESTS += nwfilterxml2xmltest
endif
if WITH_ESX
-TESTS += esxutilstest vmx2xmltest xml2vmxtest
+TESTS += esxutilstest
+endif
+
+if WITH_VMX
+TESTS += vmx2xmltest xml2vmxtest
endif
if WITH_SECDRIVER_SELINUX
@@ -292,18 +300,22 @@ esxutilstest_SOURCES = \
esxutilstest.c \
testutils.c testutils.h
esxutilstest_LDADD = ../src/libvirt_driver_esx.la $(LDADDS)
+else
+EXTRA_DIST += esxutilstest.c
+endif
+if WITH_VMX
vmx2xmltest_SOURCES = \
vmx2xmltest.c \
testutils.c testutils.h
-vmx2xmltest_LDADD = ../src/libvirt_driver_esx.la $(LDADDS)
+vmx2xmltest_LDADD = ../src/libvirt_vmx.la $(LDADDS)
xml2vmxtest_SOURCES = \
xml2vmxtest.c \
testutils.c testutils.h
-xml2vmxtest_LDADD = ../src/libvirt_driver_esx.la $(LDADDS)
+xml2vmxtest_LDADD = ../src/libvirt_vmx.la $(LDADDS)
else
-EXTRA_DIST += esxutilstest.c vmx2xmltest.c xml2vmxtest.c
+EXTRA_DIST += vmx2xmltest.c xml2vmxtest.c
endif
networkxml2xmltest_SOURCES = \
diff --git a/tests/esxutilstest.c b/tests/esxutilstest.c
index 97e154e..b6bf87b 100644
--- a/tests/esxutilstest.c
+++ b/tests/esxutilstest.c
@@ -10,6 +10,7 @@
# include "memory.h"
# include "testutils.h"
# include "util.h"
+# include "vmx/vmx.h"
# include "esx/esx_util.h"
# include "esx/esx_vi_types.h"
@@ -303,8 +304,8 @@ testConvertWindows1252ToUTF8(const void *data ATTRIBUTE_UNUSED)
for (i = 0; i < ARRAY_CARDINALITY(windows1252ToUTF8); ++i) {
VIR_FREE(utf8);
- utf8 = esxUtil_ConvertToUTF8("Windows-1252",
- windows1252ToUTF8[i].windows1252);
+ utf8 = virVMXConvertToUTF8("Windows-1252",
+ windows1252ToUTF8[i].windows1252);
if (utf8 == NULL) {
return -1;
diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c
index ba50034..9378db3 100644
--- a/tests/vmx2xmltest.c
+++ b/tests/vmx2xmltest.c
@@ -1,6 +1,6 @@
#include <config.h>
-#ifdef WITH_ESX
+#ifdef WITH_VMX
# include <stdio.h>
# include <string.h>
@@ -9,12 +9,12 @@
# include "internal.h"
# include "memory.h"
# include "testutils.h"
-# include "esx/esx_vmx.h"
+# include "vmx/vmx.h"
static char *progname = NULL;
static char *abs_srcdir = NULL;
static virCapsPtr caps = NULL;
-static esxVMX_Context ctx;
+static virVMXContext ctx;
# define MAX_FILE 4096
@@ -68,8 +68,7 @@ testCapsInit(void)
}
static int
-testCompareFiles(const char *vmx, const char *xml,
- esxVI_ProductVersion productVersion)
+testCompareFiles(const char *vmx, const char *xml)
{
int result = -1;
char vmxData[MAX_FILE];
@@ -88,7 +87,7 @@ testCompareFiles(const char *vmx, const char *xml,
goto failure;
}
- def = esxVMX_ParseConfig(&ctx, caps, vmxData, productVersion);
+ def = virVMXParseConfig(&ctx, caps, vmxData);
if (def == NULL) {
err = virGetLastError();
@@ -121,7 +120,6 @@ testCompareFiles(const char *vmx, const char *xml,
struct testInfo {
const char *input;
const char *output;
- esxVI_ProductVersion version;
};
static int
@@ -136,7 +134,7 @@ testCompareHelper(const void *data)
snprintf(xml, PATH_MAX, "%s/vmx2xmldata/vmx2xml-%s.xml", abs_srcdir,
info->output);
- return testCompareFiles(vmx, xml, info->version);
+ return testCompareFiles(vmx, xml);
}
static char *
@@ -206,9 +204,9 @@ mymain(int argc, char **argv)
return EXIT_FAILURE;
}
-# define DO_TEST(_in, _out, _version) \
+# define DO_TEST(_in, _out) \
do { \
- struct testInfo info = { _in, _out, _version }; \
+ struct testInfo info = { _in, _out }; \
virResetLastError(); \
if (virtTestRun("VMware VMX-2-XML "_in" -> "_out, 1, \
testCompareHelper, &info) < 0) { \
@@ -227,65 +225,65 @@ mymain(int argc, char **argv)
ctx.formatFileName = NULL;
ctx.autodetectSCSIControllerModel = NULL;
- DO_TEST("case-insensitive-1", "case-insensitive-1", esxVI_ProductVersion_ESX35);
- DO_TEST("case-insensitive-2", "case-insensitive-2", esxVI_ProductVersion_ESX35);
+ DO_TEST("case-insensitive-1", "case-insensitive-1");
+ DO_TEST("case-insensitive-2", "case-insensitive-2");
- DO_TEST("minimal", "minimal", esxVI_ProductVersion_ESX35);
- DO_TEST("minimal-64bit", "minimal-64bit", esxVI_ProductVersion_ESX35);
+ DO_TEST("minimal", "minimal");
+ DO_TEST("minimal-64bit", "minimal-64bit");
- DO_TEST("graphics-vnc", "graphics-vnc", esxVI_ProductVersion_ESX35);
+ DO_TEST("graphics-vnc", "graphics-vnc");
- DO_TEST("scsi-driver", "scsi-driver", esxVI_ProductVersion_ESX35);
- DO_TEST("scsi-writethrough", "scsi-writethrough", esxVI_ProductVersion_ESX35);
+ DO_TEST("scsi-driver", "scsi-driver");
+ DO_TEST("scsi-writethrough", "scsi-writethrough");
- DO_TEST("harddisk-scsi-file", "harddisk-scsi-file", esxVI_ProductVersion_ESX35);
- DO_TEST("harddisk-ide-file", "harddisk-ide-file", esxVI_ProductVersion_ESX35);
+ DO_TEST("harddisk-scsi-file", "harddisk-scsi-file");
+ DO_TEST("harddisk-ide-file", "harddisk-ide-file");
- DO_TEST("cdrom-scsi-file", "cdrom-scsi-file", esxVI_ProductVersion_ESX35);
- DO_TEST("cdrom-scsi-device", "cdrom-scsi-device", esxVI_ProductVersion_ESX35);
- DO_TEST("cdrom-ide-file", "cdrom-ide-file", esxVI_ProductVersion_ESX35);
- DO_TEST("cdrom-ide-device", "cdrom-ide-device", esxVI_ProductVersion_ESX35);
+ DO_TEST("cdrom-scsi-file", "cdrom-scsi-file");
+ DO_TEST("cdrom-scsi-device", "cdrom-scsi-device");
+ DO_TEST("cdrom-ide-file", "cdrom-ide-file");
+ DO_TEST("cdrom-ide-device", "cdrom-ide-device");
- DO_TEST("floppy-file", "floppy-file", esxVI_ProductVersion_ESX35);
- DO_TEST("floppy-device", "floppy-device", esxVI_ProductVersion_ESX35);
+ DO_TEST("floppy-file", "floppy-file");
+ DO_TEST("floppy-device", "floppy-device");
- DO_TEST("ethernet-e1000", "ethernet-e1000", esxVI_ProductVersion_ESX35);
- DO_TEST("ethernet-vmxnet2", "ethernet-vmxnet2", esxVI_ProductVersion_ESX35);
+ DO_TEST("ethernet-e1000", "ethernet-e1000");
+ DO_TEST("ethernet-vmxnet2", "ethernet-vmxnet2");
- DO_TEST("ethernet-custom", "ethernet-custom", esxVI_ProductVersion_ESX35);
- DO_TEST("ethernet-bridged", "ethernet-bridged", esxVI_ProductVersion_ESX35);
+ DO_TEST("ethernet-custom", "ethernet-custom");
+ DO_TEST("ethernet-bridged", "ethernet-bridged");
- DO_TEST("ethernet-generated", "ethernet-generated", esxVI_ProductVersion_ESX35);
- DO_TEST("ethernet-static", "ethernet-static", esxVI_ProductVersion_ESX35);
- DO_TEST("ethernet-vpx", "ethernet-vpx", esxVI_ProductVersion_ESX35);
- DO_TEST("ethernet-other", "ethernet-other", esxVI_ProductVersion_ESX35);
+ DO_TEST("ethernet-generated", "ethernet-generated");
+ DO_TEST("ethernet-static", "ethernet-static");
+ DO_TEST("ethernet-vpx", "ethernet-vpx");
+ DO_TEST("ethernet-other", "ethernet-other");
- DO_TEST("serial-file", "serial-file", esxVI_ProductVersion_ESX35);
- DO_TEST("serial-device", "serial-device", esxVI_ProductVersion_ESX35);
- DO_TEST("serial-pipe-client-app", "serial-pipe", esxVI_ProductVersion_ESX35);
- DO_TEST("serial-pipe-server-vm", "serial-pipe", esxVI_ProductVersion_ESX35);
- DO_TEST("serial-pipe-client-app", "serial-pipe", esxVI_ProductVersion_ESX35);
- DO_TEST("serial-pipe-server-vm", "serial-pipe", esxVI_ProductVersion_ESX35);
- DO_TEST("serial-network-server", "serial-network-server", esxVI_ProductVersion_ESX41);
- DO_TEST("serial-network-client", "serial-network-client", esxVI_ProductVersion_ESX41);
+ DO_TEST("serial-file", "serial-file");
+ DO_TEST("serial-device", "serial-device");
+ DO_TEST("serial-pipe-client-app", "serial-pipe");
+ DO_TEST("serial-pipe-server-vm", "serial-pipe");
+ DO_TEST("serial-pipe-client-app", "serial-pipe");
+ DO_TEST("serial-pipe-server-vm", "serial-pipe");
+ DO_TEST("serial-network-server", "serial-network-server");
+ DO_TEST("serial-network-client", "serial-network-client");
- DO_TEST("parallel-file", "parallel-file", esxVI_ProductVersion_ESX35);
- DO_TEST("parallel-device", "parallel-device", esxVI_ProductVersion_ESX35);
+ DO_TEST("parallel-file", "parallel-file");
+ DO_TEST("parallel-device", "parallel-device");
- DO_TEST("esx-in-the-wild-1", "esx-in-the-wild-1", esxVI_ProductVersion_ESX35);
- DO_TEST("esx-in-the-wild-2", "esx-in-the-wild-2", esxVI_ProductVersion_ESX35);
- DO_TEST("esx-in-the-wild-3", "esx-in-the-wild-3", esxVI_ProductVersion_ESX35);
- DO_TEST("esx-in-the-wild-4", "esx-in-the-wild-4", esxVI_ProductVersion_ESX35);
- DO_TEST("esx-in-the-wild-5", "esx-in-the-wild-5", esxVI_ProductVersion_ESX40);
+ DO_TEST("esx-in-the-wild-1", "esx-in-the-wild-1");
+ DO_TEST("esx-in-the-wild-2", "esx-in-the-wild-2");
+ DO_TEST("esx-in-the-wild-3", "esx-in-the-wild-3");
+ DO_TEST("esx-in-the-wild-4", "esx-in-the-wild-4");
+ DO_TEST("esx-in-the-wild-5", "esx-in-the-wild-5");
- DO_TEST("gsx-in-the-wild-1", "gsx-in-the-wild-1", esxVI_ProductVersion_ESX35);
- DO_TEST("gsx-in-the-wild-2", "gsx-in-the-wild-2", esxVI_ProductVersion_ESX35);
- DO_TEST("gsx-in-the-wild-3", "gsx-in-the-wild-3", esxVI_ProductVersion_ESX35);
- DO_TEST("gsx-in-the-wild-4", "gsx-in-the-wild-4", esxVI_ProductVersion_ESX35);
+ DO_TEST("gsx-in-the-wild-1", "gsx-in-the-wild-1");
+ DO_TEST("gsx-in-the-wild-2", "gsx-in-the-wild-2");
+ DO_TEST("gsx-in-the-wild-3", "gsx-in-the-wild-3");
+ DO_TEST("gsx-in-the-wild-4", "gsx-in-the-wild-4");
- DO_TEST("annotation", "annotation", esxVI_ProductVersion_ESX35);
+ DO_TEST("annotation", "annotation");
- DO_TEST("smbios", "smbios", esxVI_ProductVersion_ESX35);
+ DO_TEST("smbios", "smbios");
virCapabilitiesFree(caps);
@@ -301,4 +299,4 @@ int main (void)
return 77; /* means 'test skipped' for automake */
}
-#endif /* WITH_ESX */
+#endif /* WITH_VMX */
diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c
index 7041877..6a39582 100644
--- a/tests/xml2vmxtest.c
+++ b/tests/xml2vmxtest.c
@@ -1,6 +1,6 @@
#include <config.h>
-#ifdef WITH_ESX
+#ifdef WITH_VMX
# include <stdio.h>
# include <string.h>
@@ -9,12 +9,12 @@
# include "internal.h"
# include "memory.h"
# include "testutils.h"
-# include "esx/esx_vmx.h"
+# include "vmx/vmx.h"
static char *progname = NULL;
static char *abs_srcdir = NULL;
static virCapsPtr caps = NULL;
-static esxVMX_Context ctx;
+static virVMXContext ctx;
# define MAX_FILE 4096
@@ -68,8 +68,7 @@ testCapsInit(void)
}
static int
-testCompareFiles(const char *xml, const char *vmx,
- esxVI_ProductVersion productVersion)
+testCompareFiles(const char *xml, const char *vmx, int virtualHW_version)
{
int result = -1;
char xmlData[MAX_FILE];
@@ -93,7 +92,7 @@ testCompareFiles(const char *xml, const char *vmx,
goto failure;
}
- formatted = esxVMX_FormatConfig(&ctx, caps, def, productVersion);
+ formatted = virVMXFormatConfig(&ctx, caps, def, virtualHW_version);
if (formatted == NULL) {
goto failure;
@@ -116,7 +115,7 @@ testCompareFiles(const char *xml, const char *vmx,
struct testInfo {
const char *input;
const char *output;
- esxVI_ProductVersion version;
+ int virtualHW_version;
};
static int
@@ -131,7 +130,7 @@ testCompareHelper(const void *data)
snprintf(vmx, PATH_MAX, "%s/xml2vmxdata/xml2vmx-%s.vmx", abs_srcdir,
info->output);
- return testCompareFiles(xml, vmx, info->version);
+ return testCompareFiles(xml, vmx, info->virtualHW_version);
}
static int
@@ -147,17 +146,35 @@ static char *
testFormatVMXFileName(const char *src, void *opaque ATTRIBUTE_UNUSED)
{
bool success = false;
+ char *copyOfDatastorePath = NULL;
+ char *tmp = NULL;
+ char *saveptr = NULL;
char *datastoreName = NULL;
char *directoryAndFileName = NULL;
char *absolutePath = NULL;
if (STRPREFIX(src, "[")) {
/* Found potential datastore path */
- if (esxUtil_ParseDatastorePath(src, &datastoreName, NULL,
- &directoryAndFileName) < 0) {
+ copyOfDatastorePath = strdup(src);
+
+ if (copyOfDatastorePath == NULL) {
+ goto cleanup;
+ }
+
+ /* Expected format: '[<datastore>] <path>' where <path> is optional */
+ if ((tmp = STRSKIP(copyOfDatastorePath, "[")) == NULL || *tmp == ']' ||
+ (datastoreName = strtok_r(tmp, "]", &saveptr)) == NULL) {
goto cleanup;
}
+ directoryAndFileName = strtok_r(NULL, "", &saveptr);
+
+ if (directoryAndFileName == NULL) {
+ directoryAndFileName = (char *)"";
+ } else {
+ directoryAndFileName += strspn(directoryAndFileName, " ");
+ }
+
virAsprintf(&absolutePath, "/vmfs/volumes/%s/%s", datastoreName,
directoryAndFileName);
} else if (STRPREFIX(src, "/")) {
@@ -175,8 +192,7 @@ testFormatVMXFileName(const char *src, void *opaque ATTRIBUTE_UNUSED)
VIR_FREE(absolutePath);
}
- VIR_FREE(datastoreName);
- VIR_FREE(directoryAndFileName);
+ VIR_FREE(copyOfDatastorePath);
return absolutePath;
}
@@ -226,59 +242,59 @@ mymain(int argc, char **argv)
ctx.formatFileName = testFormatVMXFileName;
ctx.autodetectSCSIControllerModel = testAutodetectSCSIControllerModel;
- DO_TEST("minimal", "minimal", esxVI_ProductVersion_ESX35);
- DO_TEST("minimal-64bit", "minimal-64bit", esxVI_ProductVersion_ESX35);
+ DO_TEST("minimal", "minimal", 4);
+ DO_TEST("minimal-64bit", "minimal-64bit", 4);
- DO_TEST("graphics-vnc", "graphics-vnc", esxVI_ProductVersion_ESX35);
+ DO_TEST("graphics-vnc", "graphics-vnc", 4);
- DO_TEST("scsi-driver", "scsi-driver", esxVI_ProductVersion_ESX35);
- DO_TEST("scsi-writethrough", "scsi-writethrough", esxVI_ProductVersion_ESX35);
+ DO_TEST("scsi-driver", "scsi-driver", 4);
+ DO_TEST("scsi-writethrough", "scsi-writethrough", 4);
- DO_TEST("harddisk-scsi-file", "harddisk-scsi-file", esxVI_ProductVersion_ESX35);
- DO_TEST("harddisk-ide-file", "harddisk-ide-file", esxVI_ProductVersion_ESX35);
+ DO_TEST("harddisk-scsi-file", "harddisk-scsi-file", 4);
+ DO_TEST("harddisk-ide-file", "harddisk-ide-file", 4);
- DO_TEST("cdrom-scsi-file", "cdrom-scsi-file", esxVI_ProductVersion_ESX35);
- DO_TEST("cdrom-scsi-device", "cdrom-scsi-device", esxVI_ProductVersion_ESX35);
- DO_TEST("cdrom-ide-file", "cdrom-ide-file", esxVI_ProductVersion_ESX35);
- DO_TEST("cdrom-ide-device", "cdrom-ide-device", esxVI_ProductVersion_ESX35);
+ DO_TEST("cdrom-scsi-file", "cdrom-scsi-file", 4);
+ DO_TEST("cdrom-scsi-device", "cdrom-scsi-device", 4);
+ DO_TEST("cdrom-ide-file", "cdrom-ide-file", 4);
+ DO_TEST("cdrom-ide-device", "cdrom-ide-device", 4);
- DO_TEST("floppy-file", "floppy-file", esxVI_ProductVersion_ESX35);
- DO_TEST("floppy-device", "floppy-device", esxVI_ProductVersion_ESX35);
+ DO_TEST("floppy-file", "floppy-file", 4);
+ DO_TEST("floppy-device", "floppy-device", 4);
- DO_TEST("ethernet-e1000", "ethernet-e1000", esxVI_ProductVersion_ESX35);
- DO_TEST("ethernet-vmxnet2", "ethernet-vmxnet2", esxVI_ProductVersion_ESX35);
+ DO_TEST("ethernet-e1000", "ethernet-e1000", 4);
+ DO_TEST("ethernet-vmxnet2", "ethernet-vmxnet2", 4);
- DO_TEST("ethernet-custom", "ethernet-custom", esxVI_ProductVersion_ESX35);
- DO_TEST("ethernet-bridged", "ethernet-bridged", esxVI_ProductVersion_ESX35);
+ DO_TEST("ethernet-custom", "ethernet-custom", 4);
+ DO_TEST("ethernet-bridged", "ethernet-bridged", 4);
- DO_TEST("ethernet-generated", "ethernet-generated", esxVI_ProductVersion_ESX35);
- DO_TEST("ethernet-static", "ethernet-static", esxVI_ProductVersion_ESX35);
- DO_TEST("ethernet-vpx", "ethernet-vpx", esxVI_ProductVersion_ESX35);
- DO_TEST("ethernet-other", "ethernet-other", esxVI_ProductVersion_ESX35);
+ DO_TEST("ethernet-generated", "ethernet-generated", 4);
+ DO_TEST("ethernet-static", "ethernet-static", 4);
+ DO_TEST("ethernet-vpx", "ethernet-vpx", 4);
+ DO_TEST("ethernet-other", "ethernet-other", 4);
- DO_TEST("serial-file", "serial-file", esxVI_ProductVersion_ESX35);
- DO_TEST("serial-device", "serial-device", esxVI_ProductVersion_ESX35);
- DO_TEST("serial-pipe", "serial-pipe", esxVI_ProductVersion_ESX35);
- DO_TEST("serial-network-server", "serial-network-server", esxVI_ProductVersion_ESX41);
- DO_TEST("serial-network-client", "serial-network-client", esxVI_ProductVersion_ESX41);
+ DO_TEST("serial-file", "serial-file", 4);
+ DO_TEST("serial-device", "serial-device", 4);
+ DO_TEST("serial-pipe", "serial-pipe", 4);
+ DO_TEST("serial-network-server", "serial-network-server", 7);
+ DO_TEST("serial-network-client", "serial-network-client", 7);
- DO_TEST("parallel-file", "parallel-file", esxVI_ProductVersion_ESX35);
- DO_TEST("parallel-device", "parallel-device", esxVI_ProductVersion_ESX35);
+ DO_TEST("parallel-file", "parallel-file", 4);
+ DO_TEST("parallel-device", "parallel-device", 4);
- DO_TEST("esx-in-the-wild-1", "esx-in-the-wild-1", esxVI_ProductVersion_ESX35);
- DO_TEST("esx-in-the-wild-2", "esx-in-the-wild-2", esxVI_ProductVersion_ESX35);
- DO_TEST("esx-in-the-wild-3", "esx-in-the-wild-3", esxVI_ProductVersion_ESX35);
- DO_TEST("esx-in-the-wild-4", "esx-in-the-wild-4", esxVI_ProductVersion_ESX35);
- DO_TEST("esx-in-the-wild-5", "esx-in-the-wild-5", esxVI_ProductVersion_ESX35);
+ DO_TEST("esx-in-the-wild-1", "esx-in-the-wild-1", 4);
+ DO_TEST("esx-in-the-wild-2", "esx-in-the-wild-2", 4);
+ DO_TEST("esx-in-the-wild-3", "esx-in-the-wild-3", 4);
+ DO_TEST("esx-in-the-wild-4", "esx-in-the-wild-4", 4);
+ DO_TEST("esx-in-the-wild-5", "esx-in-the-wild-5", 4);
- DO_TEST("gsx-in-the-wild-1", "gsx-in-the-wild-1", esxVI_ProductVersion_ESX35);
- DO_TEST("gsx-in-the-wild-2", "gsx-in-the-wild-2", esxVI_ProductVersion_ESX35);
- DO_TEST("gsx-in-the-wild-3", "gsx-in-the-wild-3", esxVI_ProductVersion_ESX35);
- DO_TEST("gsx-in-the-wild-4", "gsx-in-the-wild-4", esxVI_ProductVersion_ESX35);
+ DO_TEST("gsx-in-the-wild-1", "gsx-in-the-wild-1", 4);
+ DO_TEST("gsx-in-the-wild-2", "gsx-in-the-wild-2", 4);
+ DO_TEST("gsx-in-the-wild-3", "gsx-in-the-wild-3", 4);
+ DO_TEST("gsx-in-the-wild-4", "gsx-in-the-wild-4", 4);
- DO_TEST("annotation", "annotation", esxVI_ProductVersion_ESX35);
+ DO_TEST("annotation", "annotation", 4);
- DO_TEST("smbios", "smbios", esxVI_ProductVersion_ESX35);
+ DO_TEST("smbios", "smbios", 4);
virCapabilitiesFree(caps);
@@ -294,4 +310,4 @@ int main (void)
return 77; /* means 'test skipped' for automake */
}
-#endif /* WITH_ESX */
+#endif /* WITH_VMX */
--
1.7.0.4
3
5
[libvirt] [PATCH] esx: Fix cluster resource lookup when connecting to a vCenter
by Matthias Bolte 21 Dec '10
by Matthias Bolte 21 Dec '10
21 Dec '10
Connecting to a ESX(i) server that is part of a cluster failed
when the connection also involved a vCenter.
Accept ClusterComputeResource type in addition to ComputeResource
type in the object lookup function.
Reported by Guillaume Le Louët.
---
src/esx/esx_vi.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 74a2a42..482a118 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -538,7 +538,7 @@ esxVI_Context_LookupObjectsByPath(esxVI_Context *ctx,
goto cleanup;
}
- /* Lookup ComputeResource */
+ /* Lookup (Cluster)ComputeResource */
esxVI_String_Free(&propertyNameList);
if (esxVI_String_AppendValueListToList(&propertyNameList,
@@ -699,7 +699,7 @@ esxVI_Context_LookupObjectsByHostSystemIp(esxVI_Context *ctx,
goto cleanup;
}
- /* Lookup ComputeResource */
+ /* Lookup (Cluster)ComputeResource */
esxVI_String_Free(&propertyNameList);
if (esxVI_String_AppendValueListToList(&propertyNameList,
@@ -1654,7 +1654,8 @@ esxVI_LookupObjectContentByType(esxVI_Context *ctx,
if (STRNEQ(root->type, type)) {
if (STREQ(root->type, "Folder")) {
- if (STREQ(type, "Datacenter") || STREQ(type, "ComputeResource")) {
+ if (STREQ(type, "Datacenter") || STREQ(type, "ComputeResource") ||
+ STREQ(type, "ClusterComputeResource")) {
objectSpec->selectSet = ctx->selectSet_folderToChildEntity;
} else {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
@@ -1662,7 +1663,8 @@ esxVI_LookupObjectContentByType(esxVI_Context *ctx,
type, root->type);
goto cleanup;
}
- } else if (STREQ(root->type, "ComputeResource")) {
+ } else if (STREQ(root->type, "ComputeResource") ||
+ STREQ(root->type, "ClusterComputeResource")) {
if (STREQ(type, "HostSystem")) {
objectSpec->selectSet = ctx->selectSet_computeResourceToHost;
} else if (STREQ(type, "Datacenter")) {
@@ -1674,7 +1676,8 @@ esxVI_LookupObjectContentByType(esxVI_Context *ctx,
goto cleanup;
}
} else if (STREQ(root->type, "HostSystem")) {
- if (STREQ(type, "ComputeResource")) {
+ if (STREQ(type, "ComputeResource") ||
+ STREQ(type, "ClusterComputeResource")) {
objectSpec->selectSet = ctx->selectSet_hostSystemToParent;
} else if (STREQ(type, "VirtualMachine")) {
objectSpec->selectSet = ctx->selectSet_hostSystemToVm;
--
1.7.0.4
2
2
* daemon/Makefile.am: Avoid spurious space before tabs.
* src/Makefile.am: Likewise.
* examples/dominfo/Makefile.am: Likewise.
* examples/domsuspend/Makefile.am: Likewise.
* tools/Makefile.am: Likewise.
* src/datatypes.h (VIR_CONNECT_MAGIC): Likewise.
* src/internal.h (TODO): Likewise.
* src/qemu/qemu_monitor.h (QEMU_MONITOR_MIGRATE): Likewise.
* src/xen/xen_hypervisor.c (XEN_V2_OP_GETAVAILHEAP): Likewise.
* src/xen/xs_internal.h: Likewise.
---
Pushing this under the trivial rule - I've got my editor set up
to highlight suspicious spacing, and when I noticed it in one
file, I decided to scrub the rest of the source tree.
There are also space-tab instances in a binary blob and in
docs/api_extension (where there are literal patchsets
containing doc changes that end up creating space-tab), but
those instances obviously should not be changed.
daemon/Makefile.am | 4 ++--
examples/dominfo/Makefile.am | 3 ++-
examples/domsuspend/Makefile.am | 3 ++-
src/Makefile.am | 4 ++--
src/datatypes.h | 4 ++--
src/internal.h | 2 +-
src/qemu/qemu_monitor.h | 2 +-
src/xen/xen_hypervisor.c | 2 +-
src/xen/xs_internal.h | 14 +++++++-------
tools/Makefile.am | 6 +++---
10 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 72778e5..3ffb7be 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -90,8 +90,8 @@ libvirtd_CFLAGS = \
-DQEMUD_PID_FILE="\"$(QEMUD_PID_FILE)\"" \
-DREMOTE_PID_FILE="\"$(REMOTE_PID_FILE)\""
-libvirtd_LDFLAGS = \
- $(WARN_CFLAGS) \
+libvirtd_LDFLAGS = \
+ $(WARN_CFLAGS) \
$(COVERAGE_LDFLAGS)
libvirtd_LDADD = \
diff --git a/examples/dominfo/Makefile.am b/examples/dominfo/Makefile.am
index 2913e5b..678de68 100644
--- a/examples/dominfo/Makefile.am
+++ b/examples/dominfo/Makefile.am
@@ -1,6 +1,7 @@
INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I@srcdir@/include
-LDADDS = $(STATIC_BINARIES) $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la $(COVERAGE_LDFLAGS)
+LDADDS = $(STATIC_BINARIES) $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la \
+ $(COVERAGE_LDFLAGS)
noinst_PROGRAMS=info1
diff --git a/examples/domsuspend/Makefile.am b/examples/domsuspend/Makefile.am
index 14b4205..2c277a4 100644
--- a/examples/domsuspend/Makefile.am
+++ b/examples/domsuspend/Makefile.am
@@ -1,6 +1,7 @@
INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I@srcdir@/include
-LDADDS = $(STATIC_BINARIES) $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la $(COVERAGE_LDFLAGS)
+LDADDS = $(STATIC_BINARIES) $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la \
+ $(COVERAGE_LDFLAGS)
noinst_PROGRAMS=suspend
diff --git a/src/Makefile.am b/src/Makefile.am
index fe34b7b..10c3c7e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -254,7 +254,7 @@ OPENVZ_DRIVER_SOURCES = \
openvz/openvz_conf.c openvz/openvz_conf.h \
openvz/openvz_driver.c openvz/openvz_driver.h
-VMWARE_DRIVER_SOURCES = \
+VMWARE_DRIVER_SOURCES = \
vmware/vmware_driver.c vmware/vmware_driver.h \
vmware/vmware_conf.c vmware/vmware_conf.h
@@ -266,7 +266,7 @@ VBOX_DRIVER_SOURCES = \
vbox/vbox_V3_1.c vbox/vbox_CAPI_v3_1.h \
vbox/vbox_V3_2.c vbox/vbox_CAPI_v3_2.h
-VBOX_DRIVER_EXTRA_DIST = \
+VBOX_DRIVER_EXTRA_DIST = \
vbox/vbox_tmpl.c vbox/README \
vbox/vbox_MSCOMGlue.c vbox/vbox_MSCOMGlue.h \
vbox/vbox_XPCOMCGlue.c vbox/vbox_XPCOMCGlue.h
diff --git a/src/datatypes.h b/src/datatypes.h
index bbeb7cf..07fa582 100644
--- a/src/datatypes.h
+++ b/src/datatypes.h
@@ -1,7 +1,7 @@
/*
* datatypes.h: management of structs for public data types
*
- * Copyright (C) 2006-2008 Red Hat, Inc.
+ * Copyright (C) 2006-2008, 2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -34,7 +34,7 @@
* magic value used to protect the API when pointers to connection structures
* are passed down by the uers.
*/
-# define VIR_CONNECT_MAGIC 0x4F23DEAD
+# define VIR_CONNECT_MAGIC 0x4F23DEAD
# define VIR_IS_CONNECT(obj) ((obj) && (obj)->magic==VIR_CONNECT_MAGIC)
diff --git a/src/internal.h b/src/internal.h
index 8473c3c..038b862 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -200,7 +200,7 @@
*
* macro to flag unimplemented blocks
*/
-# define TODO \
+# define TODO \
fprintf(stderr, "Unimplemented block at %s:%d\n", \
__FILE__, __LINE__);
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 4d7aaf7..3ac5024 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -247,7 +247,7 @@ int qemuMonitorGetMigrationStatus(qemuMonitorPtr mon,
unsigned long long *total);
typedef enum {
- QEMU_MONITOR_MIGRATE_BACKGROUND = 1 << 0,
+ QEMU_MONITOR_MIGRATE_BACKGROUND = 1 << 0,
QEMU_MONITOR_MIGRATE_NON_SHARED_DISK = 1 << 1, /* migration with non-shared storage with full disk copy */
QEMU_MONITOR_MIGRATE_NON_SHARED_INC = 1 << 2, /* migration with non-shared storage with incremental copy */
QEMU_MONITOR_MIGRATION_FLAGS_LAST
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index b7661c0..ead8ee9 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -647,7 +647,7 @@ typedef struct xen_v2d5_setvcpumap xen_v2d5_getvcpumap;
/*
* from V2 we get the available heap information
*/
-#define XEN_V2_OP_GETAVAILHEAP 9
+#define XEN_V2_OP_GETAVAILHEAP 9
/*
* from V2 we get the scheduler parameter
diff --git a/src/xen/xs_internal.h b/src/xen/xs_internal.h
index afbc15a..d58e6c0 100644
--- a/src/xen/xs_internal.h
+++ b/src/xen/xs_internal.h
@@ -1,7 +1,7 @@
/*
* xs_internal.h: internal API for access to XenStore
*
- * Copyright (C) 2006 Red Hat, Inc.
+ * Copyright (C) 2006, 2010 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -24,17 +24,17 @@ int xenStoreClose (virConnectPtr conn);
int xenStoreGetDomainInfo (virDomainPtr domain,
virDomainInfoPtr info);
int xenStoreNumOfDomains (virConnectPtr conn);
-int xenStoreListDomains (virConnectPtr conn,
+int xenStoreListDomains (virConnectPtr conn,
int *ids,
int maxids);
-virDomainPtr xenStoreLookupByName(virConnectPtr conn,
+virDomainPtr xenStoreLookupByName(virConnectPtr conn,
const char *name);
-unsigned long xenStoreGetMaxMemory (virDomainPtr domain);
+unsigned long xenStoreGetMaxMemory (virDomainPtr domain);
int xenStoreDomainSetMemory (virDomainPtr domain,
unsigned long memory);
-unsigned long xenStoreDomainGetMaxMemory(virDomainPtr domain);
-int xenStoreDomainShutdown (virDomainPtr domain);
-int xenStoreDomainReboot (virDomainPtr domain,
+unsigned long xenStoreDomainGetMaxMemory(virDomainPtr domain);
+int xenStoreDomainShutdown (virDomainPtr domain);
+int xenStoreDomainReboot (virDomainPtr domain,
unsigned int flags);
int xenStoreDomainGetVNCPort(virConnectPtr conn,
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 8a5fb52..271c11b 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -9,9 +9,9 @@ ICON_FILES = \
virsh_win_icon.rc
EXTRA_DIST = \
- $(ICON_FILES) \
- virt-xml-validate.in \
- virt-pki-validate.in \
+ $(ICON_FILES) \
+ virt-xml-validate.in \
+ virt-pki-validate.in \
virsh.pod \
libvirt-guests.init.in \
libvirt-guests.sysconf
--
1.7.3.3
1
0
* src/util/command.c (virCommandRun): Don't capture output on
daemons.
* tests/commandtest.c (test18): Expose the bug.
Reported by Laine Stump.
---
Even though 'test4' in commandtest created a daemon, the daemon
exits rather quickly, so that no one noticed the problem. And
the existing qemu daemon use of virCommand was supplying log
file descriptors, rather than letting virCommand capture output.
I've verified that with just the tests/ changes, that the testsuite
fails (termination due to SIGALRM).
src/util/command.c | 24 ++++++++++++++----------
tests/commandtest.c | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 10 deletions(-)
diff --git a/src/util/command.c b/src/util/command.c
index f9d475e..abd2dc4 100644
--- a/src/util/command.c
+++ b/src/util/command.c
@@ -1008,17 +1008,21 @@ virCommandRun(virCommandPtr cmd, int *exitstatus)
}
/* If caller hasn't requested capture of stdout/err, then capture
- * it ourselves so we can log it.
+ * it ourselves so we can log it. But the intermediate child for
+ * a daemon has no expected output, and we don't want our
+ * capturing pipes passed on to the daemon grandchild.
*/
- if (!cmd->outfdptr) {
- cmd->outfdptr = &cmd->outfd;
- cmd->outbuf = &outbuf;
- string_io = true;
- }
- if (!cmd->errfdptr) {
- cmd->errfdptr = &cmd->errfd;
- cmd->errbuf = &errbuf;
- string_io = true;
+ if (!(cmd->flags & VIR_EXEC_DAEMON)) {
+ if (!cmd->outfdptr) {
+ cmd->outfdptr = &cmd->outfd;
+ cmd->outbuf = &outbuf;
+ string_io = true;
+ }
+ if (!cmd->errfdptr) {
+ cmd->errfdptr = &cmd->errfd;
+ cmd->errbuf = &errbuf;
+ string_io = true;
+ }
}
if (virCommandRunAsync(cmd, NULL) < 0) {
diff --git a/tests/commandtest.c b/tests/commandtest.c
index 333dd4d..38a7816 100644
--- a/tests/commandtest.c
+++ b/tests/commandtest.c
@@ -668,6 +668,47 @@ cleanup:
return ret;
}
+/*
+ * Run long-running daemon, to ensure no hang.
+ */
+static int test18(const void *unused ATTRIBUTE_UNUSED)
+{
+ virCommandPtr cmd = virCommandNewArgList("sleep", "100", NULL);
+ char *pidfile = virFilePid(abs_builddir, "commandhelper");
+ pid_t pid;
+ int ret = -1;
+
+ if (!pidfile)
+ goto cleanup;
+
+ virCommandSetPidFile(cmd, pidfile);
+ virCommandDaemonize(cmd);
+
+ alarm(5);
+ if (virCommandRun(cmd, NULL) < 0) {
+ virErrorPtr err = virGetLastError();
+ printf("Cannot run child %s\n", err->message);
+ goto cleanup;
+ }
+ alarm(0);
+
+ if (virFileReadPid(abs_builddir, "commandhelper", &pid) != 0) {
+ printf("cannot read pidfile\n");
+ goto cleanup;
+ }
+ while (kill(pid, SIGINT) != -1)
+ usleep(100*1000);
+
+ ret = 0;
+
+cleanup:
+ virCommandFree(cmd);
+ unlink(pidfile);
+ VIR_FREE(pidfile);
+ return ret;
+}
+
+
static int
mymain(int argc, char **argv)
{
@@ -732,6 +773,7 @@ mymain(int argc, char **argv)
DO_TEST(test15);
DO_TEST(test16);
DO_TEST(test17);
+ DO_TEST(test18);
return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
--
1.7.3.3
2
2
Hi all,
There's a lot of documentation for libvirt that needs improving, so wondering
if anyone would be interested in forming a libvirt "docs" team to help make
that happen?
While some of the documentation needs people familiar with specific pieces
of libvirt, there's also a lot that doesn't, and just needs people with some free
time and willingness to help.
Anyone up for it? :)
Regards and best wishes,
Justin Clift
4
8
[libvirt] [PATCH] [v3] storage: Ignore dangling symbolic link for filesystem pool
by Osier Yang 21 Dec '10
by Osier Yang 21 Dec '10
21 Dec '10
If there is a dangling symbolic link in filesystem pool, the pool
will fail to start or refresh, this patch is to fix it by ignoring
it with a warning log.
---
src/storage/storage_backend.c | 10 +++++++++-
src/storage/storage_backend_fs.c | 2 +-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 10ea33c..f4a17a2 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -977,7 +977,8 @@ virStorageBackendForType(int type) {
/*
* Allows caller to silently ignore files with improper mode
*
- * Returns -1 on error, -2 if file mode is unexpected.
+ * Returns -1 on error, -2 if file mode is unexpected or the
+ * volume is a dangling symbolic link.
*/
int
virStorageBackendVolOpenCheckMode(const char *path, unsigned int flags)
@@ -986,6 +987,13 @@ virStorageBackendVolOpenCheckMode(const char *path, unsigned int flags)
struct stat sb;
if ((fd = open(path, O_RDONLY|O_NONBLOCK|O_NOCTTY)) < 0) {
+ if (stat(path, &sb) < 0 &&
+ (errno == ENOENT || errno == ELOOP)) {
+ VIR_WARN(_("cannot open volume '%s' :%s"), path,
+ strerror(errno));
+ return -2;
+ }
+
virReportSystemError(errno,
_("cannot open volume '%s'"),
path);
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index d916d2d..ff39d48 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -651,7 +651,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED,
goto cleanup;
else {
/* Silently ignore non-regular files,
- * eg '.' '..', 'lost+found' */
+ * eg '.' '..', 'lost+found', dangling symbolic link */
virStorageVolDefFree(vol);
vol = NULL;
continue;
--
1.7.3.2
2
2
21 Dec '10
Network disks are accessed by qemu directly, and have no
associated file on the host, so checking for file ownership etc.
is unnecessary.
Signed-off-by: Josh Durgin <joshd(a)hq.newdream.net>
---
src/conf/domain_conf.c | 2 +-
src/qemu/qemu_security_dac.c | 2 +-
src/security/security_apparmor.c | 2 +-
src/security/security_selinux.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d516fbe..c857a89 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8353,7 +8353,7 @@ int virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
size_t depth = 0;
char *nextpath = NULL;
- if (!disk->src)
+ if (!disk->src || disk->type == VIR_DOMAIN_DISK_TYPE_NETWORK)
return 0;
if (disk->driverType) {
diff --git a/src/qemu/qemu_security_dac.c b/src/qemu/qemu_security_dac.c
index 55dc0c6..88fdb8d 100644
--- a/src/qemu/qemu_security_dac.c
+++ b/src/qemu/qemu_security_dac.c
@@ -144,7 +144,7 @@ qemuSecurityDACRestoreSecurityImageLabelInt(virSecurityDriverPtr drv ATTRIBUTE_U
if (disk->readonly || disk->shared)
return 0;
- if (!disk->src)
+ if (!disk->src || disk->type == VIR_DOMAIN_DISK_TYPE_NETWORK)
return 0;
/* If we have a shared FS & doing migrated, we must not
diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c
index b43c4ac..468d0a3 100644
--- a/src/security/security_apparmor.c
+++ b/src/security/security_apparmor.c
@@ -619,7 +619,7 @@ AppArmorSetSecurityImageLabel(virSecurityDriverPtr drv,
if (secdef->type == VIR_DOMAIN_SECLABEL_STATIC)
return 0;
- if (!disk->src)
+ if (!disk->src || disk->type == VIR_DOMAIN_DISK_TYPE_NETWORK)
return 0;
if (secdef->imagelabel) {
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 49efa75..47da677 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -436,7 +436,7 @@ SELinuxRestoreSecurityImageLabelInt(virSecurityDriverPtr drv ATTRIBUTE_UNUSED,
if (disk->readonly || disk->shared)
return 0;
- if (!disk->src)
+ if (!disk->src || disk->type == VIR_DOMAIN_DISK_TYPE_NETWORK)
return 0;
/* If we have a shared FS & doing migrated, we must not
--
1.7.2.3
2
1
Hi all,
Has anyone looked at adding support for Parallels virtualisation products, or
have any idea if it's even possible? Google isn't showing much in the way
of search results, so not sure it's been looked at before.
These are the server oriented products:
http://www.parallels.com/au/products/server/
They have a hosted hypervisor (like VMware GSX/Server), and a bare metal
hypervisor. They also have desktop oriented products:
http://www.parallels.com/au/computing/
1
0