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
- 40173 discussions
[libvirt] [PATCH] Blank out invalid interface names with escaped letters etc.
by Stefan Berger 31 Mar '10
by Stefan Berger 31 Mar '10
31 Mar '10
Hunt interface names through a regular expression matcher to check whether they only contain valid characters.
Valid characters in this code are currently a-z,A-Z,0-9, and '_'.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
---
src/conf/domain_conf.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
Index: libvirt-acl/src/conf/domain_conf.c
===================================================================
--- libvirt-acl.orig/src/conf/domain_conf.c
+++ libvirt-acl/src/conf/domain_conf.c
@@ -28,6 +28,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <dirent.h>
+#include <regex.h>
#include "virterror_internal.h"
#include "datatypes.h"
@@ -1776,6 +1777,23 @@ cleanup:
}
+static bool
+isValidIfname(const char *ifname) {
+ int rc = 1;
+ regex_t regex_ifname;
+
+ if (regcomp(®ex_ifname, "^[a-zA-Z0-9_]+$",
+ REG_NOSUB|REG_EXTENDED) != 0)
+ return 0;
+
+ if (regexec(®ex_ifname, ifname, 0, NULL, 0) != 0)
+ rc = 0;
+
+ regfree(®ex_ifname);
+ return rc;
+}
+
+
/* Parse the XML definition for a network interface
* @param node XML nodeset to parse for net definition
@@ -1859,8 +1877,10 @@ virDomainNetDefParseXML(virCapsPtr caps,
xmlStrEqual(cur->name, BAD_CAST "target")) {
ifname = virXMLPropString(cur, "dev");
if ((ifname != NULL) &&
- (STRPREFIX((const char*)ifname, "vnet"))) {
+ ((STRPREFIX((const char*)ifname, "vnet")) ||
+ (!isValidIfname(ifname)))) {
/* An auto-generated target name, blank it out */
+ /* blank out invalid interface names */
VIR_FREE(ifname);
}
} else if ((script == NULL) &&
3
2
31 Mar '10
virStrToLong* guarantees (via strtol) that the end pointer will be set
to the point at which parsing stopped (even on failure, this point is
the start of the input string).
* src/esx/esx_driver.c (esxGetVersion): Remove pointless
conditional.
* src/qemu/qemu_conf.c (qemuParseCommandLinePCI)
(qemuParseCommandLineUSB, qemuParseCommandLineSmp): Likewise.
* src/qemu/qemu_monitor_text.c
(qemuMonitorTextGetMigrationStatus): Likewise.
---
src/esx/esx_driver.c | 6 ++----
src/qemu/qemu_conf.c | 14 ++++++--------
src/qemu/qemu_monitor_text.c | 6 +++---
3 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index bbe8a51..f07493e 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -690,13 +690,11 @@ esxGetVersion(virConnectPtr conn, unsigned long *version)
temp = (char *)priv->host->service->about->version;
/* Expecting 'major.minor.release' format */
- if (virStrToLong_ui(temp, &temp, 10, &major) < 0 || temp == NULL ||
- *temp != '.') {
+ if (virStrToLong_ui(temp, &temp, 10, &major) < 0 || *temp != '.') {
goto failure;
}
- if (virStrToLong_ui(temp + 1, &temp, 10, &minor) < 0 || temp == NULL ||
- *temp != '.') {
+ if (virStrToLong_ui(temp + 1, &temp, 10, &minor) < 0 || *temp != '.') {
goto failure;
}
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 8f6f7ec..5d0b211 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -5217,14 +5217,14 @@ qemuParseCommandLinePCI(const char *val)
}
start = val + strlen("host=");
- if (virStrToLong_i(start, &end, 16, &bus) < 0 || !end || *end != ':') {
+ if (virStrToLong_i(start, &end, 16, &bus) < 0 || *end != ':') {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot extract PCI device bus '%s'"), val);
VIR_FREE(def);
goto cleanup;
}
start = end + 1;
- if (virStrToLong_i(start, &end, 16, &slot) < 0 || !end || *end != '.') {
+ if (virStrToLong_i(start, &end, 16, &slot) < 0 || *end != '.') {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot extract PCI device slot '%s'"), val);
VIR_FREE(def);
@@ -5275,7 +5275,7 @@ qemuParseCommandLineUSB(const char *val)
start = val + strlen("host:");
if (strchr(start, ':')) {
- if (virStrToLong_i(start, &end, 16, &first) < 0 || !end || *end != ':') {
+ if (virStrToLong_i(start, &end, 16, &first) < 0 || *end != ':') {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot extract USB device vendor '%s'"), val);
VIR_FREE(def);
@@ -5289,7 +5289,7 @@ qemuParseCommandLineUSB(const char *val)
goto cleanup;
}
} else {
- if (virStrToLong_i(start, &end, 10, &first) < 0 || !end || *end != '.') {
+ if (virStrToLong_i(start, &end, 10, &first) < 0 || *end != '.') {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot extract USB device bus '%s'"), val);
VIR_FREE(def);
@@ -5573,13 +5573,11 @@ qemuParseCommandLineSmp(virDomainDefPtr dom,
for (i = 0; i < nkws; i++) {
if (vals[i] == NULL) {
if (i > 0 ||
- virStrToLong_i(kws[i], &end, 10, &n) < 0 ||
- !end || *end != '\0')
+ virStrToLong_i(kws[i], &end, 10, &n) < 0 || *end != '\0')
goto syntax;
dom->vcpus = n;
} else {
- if (virStrToLong_i(vals[i], &end, 10, &n) < 0 ||
- !end || *end != '\0')
+ if (virStrToLong_i(vals[i], &end, 10, &n) < 0 || *end != '\0')
goto syntax;
if (STREQ(kws[i], "sockets"))
sockets = n;
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 1596e59..a199de7 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -1075,7 +1075,7 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
goto done;
tmp += strlen(MIGRATION_TRANSFER_PREFIX);
- if (virStrToLong_ull(tmp, &end, 10, transferred) < 0 || !end) {
+ if (virStrToLong_ull(tmp, &end, 10, transferred) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse migration data transferred statistic %s"), tmp);
goto cleanup;
@@ -1087,7 +1087,7 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
goto done;
tmp += strlen(MIGRATION_REMAINING_PREFIX);
- if (virStrToLong_ull(tmp, &end, 10, remaining) < 0 || !end) {
+ if (virStrToLong_ull(tmp, &end, 10, remaining) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse migration data remaining statistic %s"), tmp);
goto cleanup;
@@ -1098,7 +1098,7 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
goto done;
tmp += strlen(MIGRATION_TOTAL_PREFIX);
- if (virStrToLong_ull(tmp, &end, 10, total) < 0 || !end) {
+ if (virStrToLong_ull(tmp, &end, 10, total) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse migration data total statistic %s"), tmp);
goto cleanup;
--
1.6.6.1
2
2
I need to get libvirt version. Using function
virConnecGetLibVersion(), I've return message like
errore: unknown error
My system settings are:
Kernel: 2.6.33
Hypervisor: QEMU 0.12.3
Libvirt: 0.7.6 (cloned from git)
The code that fails is in src/libvirt.c:1656
=========================================================
if (conn->driver->libvirtVersion) {
ret = conn->driver->libvirtVersion(conn, libVer);
if (ret < 0)
goto error;
return ret;
}
*libVer = LIBVIR_VERSION_NUMBER;
ret = 0;
error:
virDispatchError(conn);
return ret;
}
=========================================================
I noticed that conn->driver->libvirtVersion is NULL for all the
hypervisors except the remote one (src/remote/remote_driver.c), hence
it always dispatch an unknown error. I checked the current libvirt
code (always cloned from git), and the bug is also present.
Is this a bug, or this is a well known behavior?
If this is a bug, a possible solution could be to add the code line
return ret;
before "error:" label. This is my debugged code
=========================================================
if (conn->driver->libvirtVersion) {
ret = conn->driver->libvirtVersion(conn, libVer);
if (ret < 0)
goto error;
return ret;
}
*libVer = LIBVIR_VERSION_NUMBER;
ret = 0;
return ret; /* POSSIBLE BUG SOLUTION */
error:
virDispatchError(conn);
return ret;
}
=========================================================
Have a good day!
--
PAOLO SMIRAGLIA
Via Avigliana 13/5
10138 Torino (TO)
Tel: 0039 333 52 73 593
E-Mail: paolo.smiraglia(a)gmail.com
- - - - -
MSN: mastronano(a)hotmail.com
Jabber: mastronano(a)jabber.linux.it
Skype: paolo.smiraglia
3
3
Call me lazy: some shells use exit (e.g. sh), others use quit (e.g. ftp),
but I never remember which. So it's faster to write a patch to make
virsh take both than it is to take a 50-50 guess, and get it wrong
in half of my attempts.
* tools/virsh.c (commands): Add 'exit'.
* tools/virsh.pod: Document it.
---
So, how many 'exit's in virsh will it take for me to have saved
more time than I spent writing up this commit message and email? :)
tools/virsh.c | 1 +
tools/virsh.pod | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index ddcc052..5c56fa6 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -8254,6 +8254,7 @@ static const vshCmdDef commands[] = {
{"pwd", cmdPwd, NULL, info_pwd},
#endif
{"quit", cmdQuit, NULL, info_quit},
+ {"exit", cmdQuit, NULL, info_quit},
{"reboot", cmdReboot, opts_reboot, info_reboot},
{"restore", cmdRestore, opts_restore, info_restore},
{"resume", cmdResume, opts_resume, info_resume},
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 9434f31..fc4a70c 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -65,7 +65,7 @@ The following commands are generic i.e. not specific to a domain.
This prints a small synopsis about all commands available for B<virsh>
B<help> I<command> will print out a detailed help message on that command.
-=item B<quit>
+=item B<quit>, B<exit>
quit this interactive terminal
--
1.6.6.1
2
2
31 Mar '10
FYI,
>From 3cda0eb487d9cafa89cd7595ed0d43ee2a93b8fc Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 31 Mar 2010 16:32:38 +0200
Subject: [PATCH] maint: fix cpp indentation syntax-check failure
* src/esx/esx_vi_types.h: Filter through cppi.
---
src/esx/esx_vi_types.h | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/esx/esx_vi_types.h b/src/esx/esx_vi_types.h
index a61cdc1..d3c7115 100644
--- a/src/esx/esx_vi_types.h
+++ b/src/esx/esx_vi_types.h
@@ -1,4 +1,3 @@
-
/*
* esx_vi_types.h: client for the VMware VI API 2.5 to manage ESX hosts
*
@@ -50,7 +49,7 @@ typedef struct _esxVI_DateTime esxVI_DateTime;
typedef struct _esxVI_Fault esxVI_Fault;
typedef struct _esxVI_ManagedObjectReference esxVI_ManagedObjectReference;
-#include "esx_vi_types.generated.typedef"
+# include "esx_vi_types.generated.typedef"
@@ -70,7 +69,7 @@ enum _esxVI_Type {
esxVI_Type_Fault,
esxVI_Type_ManagedObjectReference,
-#include "esx_vi_types.generated.typeenum"
+# include "esx_vi_types.generated.typeenum"
esxVI_Type_Other,
};
@@ -294,6 +293,6 @@ int esxVI_ManagedObjectReference_Deserialize
-#include "esx_vi_types.generated.h"
+# include "esx_vi_types.generated.h"
#endif /* __ESX_VI_TYPES_H__ */
--
1.7.0.3.513.gc8ed0
1
0
[libvirt] [PATCH] esx: Generate most SOAP mapping and improve inheritance handling
by Matthias Bolte 31 Mar '10
by Matthias Bolte 31 Mar '10
31 Mar '10
The Python script generates the mappings based on the type descriptions
in the esx_vi_generator.input file.
This also improves the inheritance handling and allows to get rid of the
ugly, inflexible, and error prone _base/_super approach. Now every struct
that represents a SOAP type contains a _type member, that allows to
recreate C++-like dynamic dispatch for "method" calls in C.
---
src/Makefile.am | 23 +-
src/esx/.gitignore | 1 +
src/esx/esx_driver.c | 10 +-
src/esx/esx_vi.c | 51 +-
src/esx/esx_vi.h | 7 +-
src/esx/esx_vi_generator.input | 426 ++++++++
src/esx/esx_vi_generator.py | 1025 ++++++++++++++++++
src/esx/esx_vi_methods.c | 44 +-
src/esx/esx_vi_types.c | 2258 +++++-----------------------------------
src/esx/esx_vi_types.h | 1090 +-------------------
10 files changed, 1868 insertions(+), 3067 deletions(-)
create mode 100644 src/esx/.gitignore
create mode 100644 src/esx/esx_vi_generator.input
create mode 100755 src/esx/esx_vi_generator.py
diff --git a/src/Makefile.am b/src/Makefile.am
index c661a5c..54792b4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -26,6 +26,8 @@ INCLUDES = \
EXTRA_DIST = $(conf_DATA)
+BUILT_SOURCES =
+
if WITH_NETWORK
UUID=$(shell uuidgen 2>/dev/null)
endif
@@ -250,6 +252,20 @@ ESX_DRIVER_SOURCES = \
esx/esx_vi_types.c esx/esx_vi_types.h \
esx/esx_vmx.c esx/esx_vmx.h
+ESX_DRIVER_GENERATED = \
+ esx/esx_vi_types.generated.c \
+ esx/esx_vi_types.generated.h \
+ esx/esx_vi_types.generated.typedef \
+ esx/esx_vi_types.generated.typeenum \
+ esx/esx_vi_types.generated.typetostring \
+ esx/esx_vi_types.generated.typefromstring
+
+ESX_DRIVER_EXTRA_DIST = \
+ esx/README \
+ esx/esx_vi_generator.input \
+ esx/esx_vi_generator.py \
+ $(ESX_DRIVER_GENERATED)
+
NETWORK_DRIVER_SOURCES = \
network/bridge_driver.h network/bridge_driver.c
@@ -594,7 +610,10 @@ libvirt_driver_one_la_SOURCES = $(ONE_DRIVER_SOURCES)
endif
+BUILT_SOURCES += $(ESX_DRIVER_GENERATED)
+$(ESX_DRIVER_GENERATED): $(srcdir)/esx/esx_vi_generator.input $(srcdir)/esx/esx_vi_generator.py
+ -srcdir=$(srcdir) $(srcdir)/esx/esx_vi_generator.py
if WITH_ESX
if WITH_DRIVER_MODULES
@@ -610,6 +629,7 @@ if WITH_DRIVER_MODULES
libvirt_driver_esx_la_LDFLAGS += -module -avoid-version
endif
libvirt_driver_esx_la_SOURCES = $(ESX_DRIVER_SOURCES)
+libvirt_driver_esx_la_DEPENDENCIES = $(ESX_DRIVER_GENERATED)
endif
if WITH_NETWORK
@@ -784,6 +804,7 @@ EXTRA_DIST += \
$(VBOX_DRIVER_SOURCES) \
$(XENAPI_DRIVER_SOURCES) \
$(ESX_DRIVER_SOURCES) \
+ $(ESX_DRIVER_EXTRA_DIST) \
$(NETWORK_DRIVER_SOURCES) \
$(INTERFACE_DRIVER_SOURCES) \
$(STORAGE_DRIVER_SOURCES) \
@@ -867,7 +888,7 @@ EXTRA_DIST += \
libvirt_macvtap.syms \
libvirt_daemon.syms
-BUILT_SOURCES = libvirt.syms
+BUILT_SOURCES += libvirt.syms
libvirt.syms: libvirt_public.syms $(USED_SYM_FILES)
rm -f $@-tmp $@
diff --git a/src/esx/.gitignore b/src/esx/.gitignore
new file mode 100644
index 0000000..29e1d48
--- /dev/null
+++ b/src/esx/.gitignore
@@ -0,0 +1 @@
+*.generated.*
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index bbe8a51..663c560 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -1924,8 +1924,14 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
perfEntityMetric = perfEntityMetric->_next) {
VIR_DEBUG0("perfEntityMetric ...");
- for (perfMetricIntSeries = perfEntityMetric->value;
- perfMetricIntSeries != NULL;
+ perfMetricIntSeries =
+ esxVI_PerfMetricIntSeries_DynamicCast(perfEntityMetric->value);
+
+ if (perfMetricIntSeries == NULL) {
+ VIR_ERROR0("QueryPerf returned object with unexpected type");
+ }
+
+ for (; perfMetricIntSeries != NULL;
perfMetricIntSeries = perfMetricIntSeries->_next) {
VIR_DEBUG0("perfMetricIntSeries ...");
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 326add7..c1fd4b4 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -3,7 +3,7 @@
* esx_vi.c: client for the VMware VI API 2.5 to manage ESX hosts
*
* 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
@@ -480,12 +480,12 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "vmFolder")) {
if (esxVI_ManagedObjectReference_CastFromAnyType
- (dynamicProperty->val, &ctx->vmFolder, "Folder")) {
+ (dynamicProperty->val, &ctx->vmFolder)) {
goto failure;
}
} else if (STREQ(dynamicProperty->name, "hostFolder")) {
if (esxVI_ManagedObjectReference_CastFromAnyType
- (dynamicProperty->val, &ctx->hostFolder, "Folder")) {
+ (dynamicProperty->val, &ctx->hostFolder)) {
goto failure;
}
} else {
@@ -725,6 +725,21 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
"Call to '%s' returned an empty result, "
"expecting a non-empty result", methodName);
goto failure;
+ } else if ((*response)->node->next != NULL) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
+ "Call to '%s' returned a list, expecting "
+ "exactly one item", methodName);
+ goto failure;
+ }
+
+ break;
+
+ case esxVI_Occurrence_RequiredList:
+ if ((*response)->node == NULL) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
+ "Call to '%s' returned an empty result, "
+ "expecting a non-empty result", methodName);
+ goto failure;
}
break;
@@ -740,7 +755,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
break;
- case esxVI_Occurrence_List:
+ case esxVI_Occurrence_OptionalList:
/* Any amount of items is valid */
break;
@@ -821,10 +836,11 @@ esxVI_Enumeration_CastFromAnyType(const esxVI_Enumeration *enumeration,
*value = 0; /* undefined */
- if (STRNEQ(anyType->other, enumeration->type)) {
+ if (anyType->type != enumeration->type) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
- "Expecting type '%s' but found '%s'", enumeration->type,
- anyType->other);
+ "Expecting type '%s' but found '%s'",
+ esxVI_Type_ToString(enumeration->type),
+ esxVI_Type_ToString(anyType->type));
return -1;
}
@@ -837,7 +853,7 @@ esxVI_Enumeration_CastFromAnyType(const esxVI_Enumeration *enumeration,
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
"Unknown value '%s' for %s", anyType->value,
- enumeration->type);
+ esxVI_Type_ToString(enumeration->type));
return -1;
}
@@ -870,7 +886,8 @@ esxVI_Enumeration_Serialize(const esxVI_Enumeration *enumeration,
return -1;
}
- ESV_VI__XML_TAG__OPEN(output, element, enumeration->type);
+ ESV_VI__XML_TAG__OPEN(output, element,
+ esxVI_Type_ToString(enumeration->type));
virBufferAdd(output, name, -1);
@@ -906,7 +923,7 @@ esxVI_Enumeration_Deserialize(const esxVI_Enumeration *enumeration,
}
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Unknown value '%s' for %s",
- name, enumeration->type);
+ name, esxVI_Type_ToString(enumeration->type));
cleanup:
VIR_FREE(name);
@@ -1009,7 +1026,7 @@ esxVI_List_CastFromAnyType(esxVI_AnyType *anyType, esxVI_List **list,
return -1;
}
- for (childNode = anyType->_node->children; childNode != NULL;
+ for (childNode = anyType->node->children; childNode != NULL;
childNode = childNode->next) {
if (childNode->type != XML_ELEMENT_NODE) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
@@ -1151,7 +1168,7 @@ esxVI_BuildFullTraversalSpecItem(esxVI_SelectionSpec **fullTraversalSpecList,
}
if (esxVI_TraversalSpec_Alloc(&traversalSpec) < 0 ||
- esxVI_String_DeepCopyValue(&traversalSpec->_base->name, name) < 0 ||
+ esxVI_String_DeepCopyValue(&traversalSpec->name, name) < 0 ||
esxVI_String_DeepCopyValue(&traversalSpec->type, type) < 0 ||
esxVI_String_DeepCopyValue(&traversalSpec->path, path) < 0) {
goto failure;
@@ -1177,7 +1194,8 @@ esxVI_BuildFullTraversalSpecItem(esxVI_SelectionSpec **fullTraversalSpecList,
}
if (esxVI_SelectionSpec_AppendToList(fullTraversalSpecList,
- traversalSpec->_base) < 0) {
+ esxVI_SelectionSpec_DynamicCast
+ (traversalSpec)) < 0) {
goto failure;
}
@@ -1721,8 +1739,7 @@ esxVI_LookupResourcePoolByHostSystem
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "parent")) {
if (esxVI_ManagedObjectReference_CastFromAnyType
- (dynamicProperty->val, &managedObjectReference,
- "ComputeResource") < 0) {
+ (dynamicProperty->val, &managedObjectReference) < 0) {
goto failure;
}
@@ -1756,7 +1773,7 @@ esxVI_LookupResourcePoolByHostSystem
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "resourcePool")) {
if (esxVI_ManagedObjectReference_CastFromAnyType
- (dynamicProperty->val, resourcePool, "ResourcePool") < 0) {
+ (dynamicProperty->val, resourcePool) < 0) {
goto failure;
}
@@ -2231,7 +2248,7 @@ esxVI_LookupPendingTaskInfoListByVirtualMachine
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "recentTask")) {
if (esxVI_ManagedObjectReference_CastListFromAnyType
- (dynamicProperty->val, &recentTaskList, "Task") < 0) {
+ (dynamicProperty->val, &recentTaskList) < 0) {
goto failure;
}
diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h
index 1349a1b..555dad5 100644
--- a/src/esx/esx_vi.h
+++ b/src/esx/esx_vi.h
@@ -2,7 +2,7 @@
/*
* esx_vi.h: client for the VMware VI API 2.5 to manage ESX hosts
*
- * 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
@@ -61,8 +61,9 @@ enum _esxVI_ProductVersion {
enum _esxVI_Occurrence {
esxVI_Occurrence_Undefined = 0,
esxVI_Occurrence_RequiredItem,
+ esxVI_Occurrence_RequiredList,
esxVI_Occurrence_OptionalItem,
- esxVI_Occurrence_List,
+ esxVI_Occurrence_OptionalList,
esxVI_Occurrence_None
};
@@ -132,7 +133,7 @@ struct _esxVI_EnumerationValue {
};
struct _esxVI_Enumeration {
- const char *type;
+ esxVI_Type type;
esxVI_EnumerationValue values[10];
};
diff --git a/src/esx/esx_vi_generator.input b/src/esx/esx_vi_generator.input
new file mode 100644
index 0000000..06dddbf
--- /dev/null
+++ b/src/esx/esx_vi_generator.input
@@ -0,0 +1,426 @@
+#
+# Definitions of vSphere API 2.5 enumeration and objects types used as input
+# for the esx_vi_generator.py script.
+#
+# This format is line-based, so end-of-line is important.
+#
+#
+# Enumeration definition:
+#
+# enum <name>
+# <value>
+# ...
+# end
+#
+#
+# Object definition:
+#
+# object <name> [extends <name>]
+# <type> <name> <occurrence>
+# ...
+# end
+#
+# Possible values for the <occurrence> field are:
+#
+# - r for a required item
+# - rl for a required list
+# - o for an optional item
+# - ol for an optional list
+# - i for an ignored item or list
+#
+# Object member sequence has to match the WSDL sequence
+#
+
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# Enumerations
+#
+
+enum ManagedEntityStatus
+ gray
+ green
+ yellow
+ red
+end
+
+
+enum ObjectUpdateKind
+ modify
+ enter
+ leave
+end
+
+
+enum PerfStatsType
+ absolute
+ delta
+ rate
+end
+
+
+enum PerfSummaryType
+ average
+ maximum
+ minimum
+ latest
+ summation
+ none
+end
+
+
+enum PropertyChangeOp
+ add
+ remove
+ assign
+ indirectRemove
+end
+
+
+enum SharesLevel
+ low
+ normal
+ high
+ custom
+end
+
+
+enum TaskInfoState
+ queued
+ running
+ success
+ error
+end
+
+
+enum VirtualMachineMovePriority
+ lowPriority
+ highPriority
+ defaultPriority
+end
+
+
+enum VirtualMachinePowerState
+ poweredOff
+ poweredOn
+ suspended
+end
+
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# Objects
+#
+
+object AboutInfo
+ String name r
+ String fullName r
+ String vendor r
+ String version r
+ String build r
+ String localeVersion o
+ String localeBuild o
+ String osType r
+ String productLineId r
+ String apiType r
+ String apiVersion r
+end
+
+
+object ChoiceOption extends OptionType
+ ElementDescription choiceInfo rl
+ Int defaultIndex o
+end
+
+
+object Description
+ String label r
+ String summary r
+end
+
+
+object DynamicProperty
+ String name r
+ AnyType val r
+end
+
+
+object ElementDescription extends Description
+ String key r
+end
+
+
+object Event
+ Int key r
+ Int chainId r
+ DateTime createdTime r
+ String userName r
+ DatacenterEventArgument datacenter i
+ ComputeResourceEventArgument computeResource i
+ HostEventArgument host i
+ VmEventArgument vm i
+ String fullFormattedMessage o
+end
+
+
+object HostCpuIdInfo
+ Int level r
+ String vendor o
+ String eax o
+ String ebx o
+ String ecx o
+ String edx o
+end
+
+
+object ObjectContent
+ ManagedObjectReference obj r
+ DynamicProperty propSet ol
+ MissingProperty missingSet i
+end
+
+
+object ObjectSpec
+ ManagedObjectReference obj r
+ Boolean skip o
+ SelectionSpec selectSet ol
+end
+
+
+object ObjectUpdate
+ ObjectUpdateKind kind r
+ ManagedObjectReference obj r
+ PropertyChange changeSet ol
+ MissingProperty missingSet i
+end
+
+
+object OptionType
+ Boolean valueIsReadonly o
+end
+
+
+object PerfCounterInfo
+ Int key r
+ ElementDescription nameInfo r
+ ElementDescription groupInfo r
+ ElementDescription unitInfo r
+ PerfSummaryType rollupType r
+ PerfStatsType statsType r
+ Int level o
+ Int associatedCounterId ol
+end
+
+
+object PerfEntityMetric extends PerfEntityMetricBase
+ PerfSampleInfo sampleInfo ol
+ PerfMetricSeries value ol
+end
+
+
+object PerfEntityMetricBase
+ ManagedObjectReference entity r
+end
+
+
+object PerfMetricId
+ Int counterId r
+ String instance r
+end
+
+
+object PerfMetricIntSeries extends PerfMetricSeries
+ Long value ol
+end
+
+
+object PerfMetricSeries
+ PerfMetricId id r
+end
+
+
+object PerfQuerySpec
+ ManagedObjectReference entity r
+ DateTime startTime o
+ DateTime endTime o
+ Int maxSample o
+ PerfMetricId metricId ol
+ Int intervalId o
+ String format o
+end
+
+
+object PerfSampleInfo
+ DateTime timestamp r
+ Int interval r
+end
+
+
+object PropertyChange
+ String name r
+ PropertyChangeOp op r
+ AnyType val o
+end
+
+
+object PropertyFilterSpec
+ PropertySpec propSet rl
+ ObjectSpec objectSet rl
+end
+
+
+object PropertyFilterUpdate
+ ManagedObjectReference filter r
+ ObjectUpdate objectSet ol
+ MissingObject missingSet i
+end
+
+
+object PropertySpec
+ String type r
+ Boolean all o
+ String pathSet ol
+end
+
+
+object ResourceAllocationInfo
+ Long reservation o
+ Boolean expandableReservation o
+ Long limit o
+ SharesInfo shares o
+ Long overheadLimit o
+end
+
+
+object ResourcePoolResourceUsage
+ Long reservationUsed r
+ Long reservationUsedForVm r
+ Long unreservedForPool r
+ Long unreservedForVm r
+ Long overallUsage r
+ Long maxUsage r
+end
+
+
+object SelectionSpec
+ String name o
+end
+
+
+object ServiceContent
+ ManagedObjectReference rootFolder r
+ ManagedObjectReference propertyCollector r
+ ManagedObjectReference viewManager o
+ AboutInfo about r
+ ManagedObjectReference setting o
+ ManagedObjectReference userDirectory o
+ ManagedObjectReference sessionManager o
+ ManagedObjectReference authorizationManager o
+ ManagedObjectReference perfManager o
+ ManagedObjectReference scheduledTaskManager o
+ ManagedObjectReference alarmManager o
+ ManagedObjectReference eventManager o
+ ManagedObjectReference taskManager o
+ ManagedObjectReference extensionManager o
+ ManagedObjectReference customizationSpecManager o
+ ManagedObjectReference customFieldsManager o
+ ManagedObjectReference accountManager o
+ ManagedObjectReference diagnosticManager o
+ ManagedObjectReference licenseManager o
+ ManagedObjectReference searchIndex o
+ ManagedObjectReference fileManager o
+ ManagedObjectReference virtualDiskManager o
+ ManagedObjectReference virtualizationManager o
+end
+
+
+object SharesInfo
+ Int shares r
+ SharesLevel level r
+end
+
+
+object TaskInfo
+ String key r
+ ManagedObjectReference task r
+ String name o
+ String descriptionId r
+ ManagedObjectReference entity o
+ String entityName o
+ ManagedObjectReference locked ol
+ TaskInfoState state r
+ Boolean cancelled r
+ Boolean cancelable r
+ LocalizedMethodFault error i
+ AnyType result o
+ Int progress o
+ TaskReason reason i
+ DateTime queueTime r
+ DateTime startTime o
+ DateTime completeTime o
+ Int eventChainId r
+end
+
+
+object TraversalSpec extends SelectionSpec
+ String type r
+ String path r
+ Boolean skip o
+ SelectionSpec selectSet ol
+end
+
+
+object UpdateSet
+ String version r
+ PropertyFilterUpdate filterSet ol
+end
+
+
+object UserSession
+ String key r
+ String userName r
+ String fullName r
+ DateTime loginTime r
+ DateTime lastActiveTime r
+ String locale r
+ String messageLocale r
+end
+
+
+object VirtualMachineConfigSpec
+ String changeVersion o
+ String name o
+ String version o
+ String uuid o
+ Long npivNodeWorldWideName ol
+ Long npivPortWorldWideName ol
+ String npivWorldWideNameType o
+ String npivWorldWideNameOp o
+ String locationId o
+ String guestId o
+ String alternateGuestName o
+ String annotation o
+ VirtualMachineFileInfo files i
+ ToolsConfigInfo tools i
+ VirtualMachineFlagInfo flags i
+ VirtualMachineConsolePreferences consolePreferences i
+ VirtualMachineDefaultPowerOpInfo powerOpInfo i
+ Int numCPUs o
+ Long memoryMB o
+ VirtualDeviceConfigSpec deviceChange i
+ ResourceAllocationInfo cpuAllocation o
+ ResourceAllocationInfo memoryAllocation o
+ VirtualMachineAffinityInfo cpuAffinity i
+ VirtualMachineAffinityInfo memoryAffinity i
+ VirtualMachineNetworkShaperInfo networkShaper i
+ VirtualMachineCpuIdInfoSpec cpuFeatureMask i
+ OptionValue extraConfig i
+ String swapPlacement o
+ VirtualMachineBootOptions bootOptions i
+end
+
+
+object VirtualMachineQuestionInfo
+ String id r
+ String text r
+ ChoiceOption choice r
+ VirtualMachineMessage message i
+end
diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py
new file mode 100755
index 0000000..5ca6138
--- /dev/null
+++ b/src/esx/esx_vi_generator.py
@@ -0,0 +1,1025 @@
+#!/usr/bin/python
+
+#
+# esx_vi_generator.py: generates most of the SOAP type mapping code
+#
+# Copyright (C) 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
+#
+
+import sys
+import os
+import os.path
+
+
+
+
+
+
+class Property:
+ OCCURRENCE__REQUIRED_ITEM = "r"
+ OCCURRENCE__REQUIRED_LIST = "rl"
+ OCCURRENCE__OPTIONAL_ITEM = "o"
+ OCCURRENCE__OPTIONAL_LIST = "ol"
+ OCCURRENCE__IGNORED = "i"
+
+ valid_occurrences = [OCCURRENCE__REQUIRED_ITEM,
+ OCCURRENCE__REQUIRED_LIST,
+ OCCURRENCE__OPTIONAL_ITEM,
+ OCCURRENCE__OPTIONAL_LIST,
+ OCCURRENCE__IGNORED]
+
+ def __init__(self, type, name, occurrence):
+ self.type = type
+ self.name = name
+ self.occurrence = occurrence
+
+ def is_enum(self):
+ global predefined_enums
+ global enums_by_name
+
+ return self.type in predefined_enums or self.type in enums_by_name
+
+ def generate_struct_member(self):
+ if self.occurrence == Property.OCCURRENCE__IGNORED:
+ return " /* FIXME: %s is currently ignored */\n" % self.name
+ else:
+ string = " %s%s; " % (self.get_type_string(), self.name)
+
+ while len(string) < 59:
+ string += " "
+
+ return string + "/* %s */\n" % self.get_occurrence_string()
+
+ def generate_free_code(self):
+ if self.type == "String" and \
+ self.occurrence not in [Property.OCCURRENCE__REQUIRED_LIST,
+ Property.OCCURRENCE__OPTIONAL_LIST,
+ Property.OCCURRENCE__IGNORED]:
+ return " VIR_FREE(item->%s);\n" % self.name
+ elif self.is_enum():
+ return ""
+ else:
+ if self.occurrence == Property.OCCURRENCE__IGNORED:
+ return " /* FIXME: %s is currently ignored */\n" % self.name
+ else:
+ return " esxVI_%s_Free(&item->%s);\n" % (self.type, self.name)
+
+ def generate_validate_code(self):
+ if self.occurrence in [Property.OCCURRENCE__REQUIRED_ITEM,
+ Property.OCCURRENCE__REQUIRED_LIST]:
+ return " ESX_VI__TEMPLATE__PROPERTY__REQUIRE(%s)\n" % self.name
+ elif self.occurrence == Property.OCCURRENCE__IGNORED:
+ return " /* FIXME: %s is currently ignored */\n" % self.name
+ else:
+ return ""
+
+ def generate_deep_copy_code(self):
+ if self.occurrence == Property.OCCURRENCE__IGNORED:
+ return " /* FIXME: %s is currently ignored */\n" % self.name
+ elif self.occurrence in [Property.OCCURRENCE__REQUIRED_LIST,
+ Property.OCCURRENCE__OPTIONAL_LIST]:
+ return " ESX_VI__TEMPLATE__PROPERTY__DEEP_COPY_LIST(%s, %s)\n" % (self.type, self.name)
+ elif self.type == "String":
+ return " ESX_VI__TEMPLATE__PROPERTY__DEEP_COPY_VALUE(String, %s)\n" % self.name
+ else:
+ return " ESX_VI__TEMPLATE__PROPERTY__DEEP_COPY(%s, %s)\n" % (self.type, self.name)
+
+ def generate_serialize_code(self):
+ if self.occurrence == Property.OCCURRENCE__IGNORED:
+ return " /* FIXME: %s is currently ignored */\n" % self.name
+ elif self.occurrence in [Property.OCCURRENCE__REQUIRED_LIST,
+ Property.OCCURRENCE__OPTIONAL_LIST]:
+ return " ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(%s, %s)\n" % (self.type, self.name)
+ elif self.type == "String":
+ return " ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, %s)\n" % self.name
+ else:
+ return " ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(%s, %s)\n" % (self.type, self.name)
+
+ def generate_deserialize_code(self):
+ if self.occurrence == Property.OCCURRENCE__IGNORED:
+ return " ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_IGNORE(%s) /* FIXME */\n" % self.name
+ elif self.occurrence in [Property.OCCURRENCE__REQUIRED_LIST,
+ Property.OCCURRENCE__OPTIONAL_LIST]:
+ return " ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_LIST(%s, %s)\n" % (self.type, self.name)
+ elif self.type == "String":
+ return " ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, %s)\n" % self.name
+ else:
+ return " ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(%s, %s)\n" % (self.type, self.name)
+
+ def get_type_string(self):
+ if self.type == "String" and \
+ self.occurrence not in [Property.OCCURRENCE__REQUIRED_LIST,
+ Property.OCCURRENCE__OPTIONAL_LIST]:
+ return "char *"
+ elif self.is_enum():
+ return "esxVI_%s " % self.type
+ else:
+ return "esxVI_%s *" % self.type
+
+ def get_occurrence_string(self):
+ if self.occurrence == Property.OCCURRENCE__REQUIRED_ITEM:
+ return "required"
+ elif self.occurrence == Property.OCCURRENCE__REQUIRED_LIST:
+ return "required, list"
+ elif self.occurrence == Property.OCCURRENCE__OPTIONAL_ITEM:
+ return "optional"
+ elif self.occurrence == Property.OCCURRENCE__OPTIONAL_LIST:
+ return "optional, list"
+
+ raise ValueError("unknown cardinality value '%s'" % self.cardinality)
+
+
+
+
+
+
+
+
+class Object:
+ FEATURE__DYNAMIC_CAST = (1 << 1)
+ FEATURE__LIST = (1 << 2)
+ FEATURE__DEEP_COPY = (1 << 3)
+ FEATURE__ANY_TYPE = (1 << 4)
+ FEATURE__SERIALIZE = (1 << 5)
+ FEATURE__DESERIALIZE = (1 << 6)
+
+ def __init__(self, name, extends, properties, features = 0, extended_by = None):
+ self.name = name
+ self.extends = extends
+ self.features = features | Object.FEATURE__SERIALIZE | Object.FEATURE__DESERIALIZE
+ self.properties = properties
+ self.extended_by = extended_by
+
+ self.properties_by_name = {}
+
+ for property in self.properties:
+ self.properties_by_name[property.name] = property
+
+ def generate_struct_members(self, add_banner = False, struct_gap = False):
+ global objects_by_name
+ members = ""
+
+ if self.extends is None:
+ struct_gap = True
+ string = " esxVI_Type _type; "
+
+ while len(string) < 59:
+ string += " "
+
+ members += string + "/* required */\n"
+
+ if struct_gap and self.extends is None:
+ members += "\n"
+
+ if self.extends is not None:
+ members += objects_by_name[self.extends].generate_struct_members(add_banner = True, struct_gap = False) + "\n"
+
+ if self.extends is not None or add_banner:
+ members += " /* %s */\n" % self.name
+
+ for property in self.properties:
+ members += property.generate_struct_member()
+
+ if len(self.properties) < 1:
+ members += " /* no properties */\n"
+
+ return members
+
+ def generate_free_code(self, add_banner = False):
+ global objects_by_name
+ source = ""
+
+ if self.extends is not None:
+ source += objects_by_name[self.extends].generate_free_code(add_banner = True) + "\n"
+
+ if self.extends is not None or add_banner:
+ source += " /* %s */\n" % self.name
+
+ if len(self.properties) < 1:
+ source += " /* no properties */\n"
+ else:
+ string = ""
+
+ for property in self.properties:
+ string += property.generate_free_code()
+
+ if len(string) < 1:
+ source += " /* no properties to be freed */\n"
+ else:
+ source += string
+
+ return source
+
+ def generate_validate_code(self, add_banner = False):
+ global objects_by_name
+ source = ""
+
+ if self.extends is not None:
+ source += objects_by_name[self.extends].generate_validate_code(add_banner = True) + "\n"
+
+ if self.extends is not None or add_banner:
+ source += " /* %s */\n" % self.name
+
+ if len(self.properties) < 1:
+ source += " /* no properties */\n"
+ else:
+ string = ""
+
+ for property in self.properties:
+ string += property.generate_validate_code()
+
+ if len(string) < 1:
+ source += " /* no required properties */\n"
+ else:
+ source += string
+
+ return source
+
+ def generate_dynamic_cast_code(self):
+ global objects_by_name
+ source = ""
+
+ if self.extended_by is not None:
+ source += " /* %s */\n" % self.name
+
+ for extended_by in self.extended_by:
+ source += " ESX_VI__TEMPLATE__DYNAMIC_CAST__ACCEPT(%s)\n" % extended_by
+
+ for extended_by in self.extended_by:
+ source += objects_by_name[extended_by].generate_dynamic_cast_code()
+
+ return source
+
+ def generate_deep_copy_code(self, add_banner = False):
+ global objects_by_name
+ source = ""
+
+ if self.extends is not None:
+ source += objects_by_name[self.extends].generate_deep_copy_code(add_banner = True) + "\n"
+
+ if self.extends is not None or add_banner:
+ source += " /* %s */\n" % self.name
+
+ if len(self.properties) < 1:
+ source += " /* no properties */\n"
+ else:
+ string = ""
+
+ for property in self.properties:
+ string += property.generate_deep_copy_code()
+
+ if len(string) < 1:
+ source += " /* no properties to be deep copied */\n"
+ else:
+ source += string
+
+ return source
+
+ def generate_serialize_code(self, add_banner = False):
+ global objects_by_name
+ source = ""
+
+ if self.extends is not None:
+ source += objects_by_name[self.extends].generate_serialize_code(add_banner = True) + "\n"
+
+ if self.extends is not None or add_banner:
+ source += " /* %s */\n" % self.name
+
+ if len(self.properties) < 1:
+ source += " /* no properties */\n"
+ else:
+ for property in self.properties:
+ source += property.generate_serialize_code()
+
+ return source
+
+ def generate_deserialize_code(self, add_banner = False):
+ global objects_by_name
+ source = ""
+
+ if self.extends is not None:
+ source += objects_by_name[self.extends].generate_deserialize_code(add_banner = True) + "\n"
+
+ if self.extends is not None or add_banner:
+ source += " /* %s */\n" % self.name
+
+ if len(self.properties) < 1:
+ source += " /* no properties */\n"
+ else:
+ for property in self.properties:
+ source += property.generate_deserialize_code()
+
+ return source
+
+ def generate_typedef(self):
+ return "typedef struct _esxVI_%s esxVI_%s;\n" % (self.name, self.name)
+
+ def generate_typeenum(self):
+ return " esxVI_Type_%s,\n" % self.name
+
+ def generate_typetostring(self):
+ string = " case esxVI_Type_%s:\n" % self.name
+ string += " return \"%s\";\n\n" % self.name
+
+ return string
+
+ def generate_typefromstring(self):
+ string = " else if (STREQ(type, \"%s\")) {\n" % self.name
+ string += " return esxVI_Type_%s;\n" % self.name
+ string += " }\n"
+
+ return string
+
+ def generate_header(self):
+ header = "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"
+ header += " * VI Type: %s\n" % self.name
+
+ if self.extends is not None:
+ header += " * extends %s\n" % self.extends
+
+ first = True
+
+ if self.extended_by is not None:
+ for extended_by in self.extended_by:
+ if first:
+ header += " * extended by %s\n" % extended_by
+ first = False
+ else:
+ header += " * %s\n" % extended_by
+
+ header += " */\n\n"
+
+ # struct
+ header += "struct _esxVI_%s {\n" % self.name
+
+ if self.features & Object.FEATURE__LIST:
+ string = " esxVI_%s *_next; " % self.name
+ else:
+ string = " esxVI_%s *_unused; " % self.name
+
+ while len(string) < 59:
+ string += " "
+
+ header += string + "/* optional */\n"
+
+ header += self.generate_struct_members(struct_gap = True)
+
+ header += "};\n\n"
+
+ # functions
+ header += "int esxVI_%s_Alloc(esxVI_%s **item);\n" % (self.name, self.name)
+ header += "void esxVI_%s_Free(esxVI_%s **item);\n" % (self.name, self.name)
+ header += "int esxVI_%s_Validate(esxVI_%s *item);\n" % (self.name, self.name)
+
+ if self.features & Object.FEATURE__DYNAMIC_CAST:
+ if self.extended_by is not None or self.extends is not None:
+ header += "esxVI_%s *esxVI_%s_DynamicCast(void *item);\n" % (self.name, self.name)
+ else:
+ report_error("cannot add dynamic cast support for an untyped object")
+
+ if self.features & Object.FEATURE__LIST:
+ header += "int esxVI_%s_AppendToList(esxVI_%s **list, esxVI_%s *item);\n" % (self.name, self.name, self.name)
+
+ if self.features & Object.FEATURE__DEEP_COPY:
+ header += "int esxVI_%s_DeepCopy(esxVI_%s **dst, esxVI_%s *src);\n" % (self.name, self.name, self.name)
+
+ if self.features & Object.FEATURE__LIST:
+ header += "int esxVI_%s_DeepCopyList(esxVI_%s **dstList, esxVI_%s *srcList);\n" % (self.name, self.name, self.name)
+
+ if self.features & Object.FEATURE__ANY_TYPE:
+ header += "int esxVI_%s_CastFromAnyType(esxVI_AnyType *anyType, esxVI_%s **item);\n" % (self.name, self.name)
+
+ if self.features & Object.FEATURE__LIST:
+ header += "int esxVI_%s_CastListFromAnyType(esxVI_AnyType *anyType, esxVI_%s **list);\n" % (self.name, self.name)
+
+ if self.features & Object.FEATURE__SERIALIZE:
+ header += "int esxVI_%s_Serialize(esxVI_%s *item, const char *element, virBufferPtr output);\n" % (self.name, self.name)
+
+ if self.features & Object.FEATURE__LIST:
+ header += "int esxVI_%s_SerializeList(esxVI_%s *list, const char *element, virBufferPtr output);\n" % (self.name, self.name)
+
+ if self.features & Object.FEATURE__DESERIALIZE:
+ header += "int esxVI_%s_Deserialize(xmlNodePtr node, esxVI_%s **item);\n" % (self.name, self.name)
+
+ if self.features & Object.FEATURE__LIST:
+ header += "int esxVI_%s_DeserializeList(xmlNodePtr node, esxVI_%s **list);\n" % (self.name, self.name)
+
+ header += "\n\n\n"
+
+ return header
+
+ def generate_source(self):
+ source = "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"
+ source += " * VI Type: %s\n" % self.name
+
+ if self.extends is not None:
+ source += " * extends %s\n" % self.extends
+
+ first = True
+
+ if self.extended_by is not None:
+ for extended_by in self.extended_by:
+ if first:
+ source += " * extended by %s\n" % extended_by
+ first = False
+ else:
+ source += " * %s\n" % extended_by
+
+ source += " */\n\n"
+
+ # functions
+ source += "/* esxVI_%s_Alloc */\n" % self.name
+ source += "ESX_VI__TEMPLATE__ALLOC(%s)\n\n" % self.name
+
+ # free
+ if self.extended_by is None:
+ source += "/* esxVI_%s_Free */\n" % self.name
+ source += "ESX_VI__TEMPLATE__FREE(%s,\n" % self.name
+ source += "{\n"
+
+ if self.features & Object.FEATURE__LIST:
+ source += " esxVI_%s_Free(&item->_next);\n\n" % self.name
+
+ source += self.generate_free_code()
+
+ source += "})\n\n"
+ else:
+ source += "/* esxVI_%s_Free */\n" % self.name
+ source += "ESX_VI__TEMPLATE__DYNAMIC_FREE(%s,\n" % self.name
+ source += "{\n"
+
+ for extended_by in self.extended_by:
+ source += " ESX_VI__TEMPLATE__DISPATCH__FREE(%s)\n" % extended_by
+
+ source += "},\n"
+ source += "{\n"
+
+ if self.features & Object.FEATURE__LIST:
+ source += " esxVI_%s_Free(&item->_next);\n\n" % self.name
+
+ source += self.generate_free_code()
+
+ source += "})\n\n"
+
+ # validate
+ source += "/* esxVI_%s_Validate */\n" % self.name
+ source += "ESX_VI__TEMPLATE__VALIDATE(%s,\n" % self.name
+ source += "{\n"
+
+ source += self.generate_validate_code()
+
+ source += "})\n\n"
+
+ # dynamic cast
+ if self.features & Object.FEATURE__DYNAMIC_CAST:
+ if self.extended_by is not None or self.extends is not None:
+ source += "/* esxVI_%s_DynamicCast */\n" % self.name
+ source += "ESX_VI__TEMPLATE__DYNAMIC_CAST(%s,\n" % self.name
+ source += "{\n"
+
+ source += self.generate_dynamic_cast_code()
+
+ source += "})\n\n"
+ else:
+ report_error("cannot add dynamic cast support for an untyped object")
+
+ # append to list
+ if self.features & Object.FEATURE__LIST:
+ source += "/* esxVI_%s_AppendToList */\n" % self.name
+ source += "ESX_VI__TEMPLATE__LIST__APPEND(%s)\n\n" % self.name
+
+ # deep copy
+ if self.extended_by is None:
+ if self.features & Object.FEATURE__DEEP_COPY:
+ source += "/* esxVI_%s_DeepCopy */\n" % self.name
+ source += "ESX_VI__TEMPLATE__DEEP_COPY(%s,\n" % self.name
+ source += "{\n"
+
+ source += self.generate_deep_copy_code()
+
+ source += "})\n\n"
+
+ if self.features & Object.FEATURE__LIST:
+ source += "/* esxVI_%s_DeepCopyList */\n" % self.name
+ source += "ESX_VI__TEMPLATE__LIST__DEEP_COPY(%s)\n\n" % self.name
+ else:
+ if self.features & Object.FEATURE__DEEP_COPY:
+ source += "/* esxVI_%s_DeepCopy */\n" % self.name
+ source += "ESX_VI__TEMPLATE__DYNAMIC_DEEP_COPY(%s)\n" % self.name
+ source += "{\n"
+
+ for extended_by in self.extended_by:
+ source += " ESX_VI__TEMPLATE__DISPATCH__DEEP_COPY(%s)\n" % extended_by
+
+ source += "},\n"
+ source += "{\n"
+
+ source += self.generate_deep_copy_code()
+
+ source += "})\n\n"
+
+ if self.features & Object.FEATURE__LIST:
+ source += "/* esxVI_%s_DeepCopyList */\n" % self.name
+ source += "ESX_VI__TEMPLATE__LIST__DEEP_COPY(%s)\n\n" % self.name
+
+ # cast from any type
+ if self.features & Object.FEATURE__ANY_TYPE:
+ source += "/* esxVI_%s_CastFromAnyType */\n" % self.name
+ source += "ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(%s)\n" % self.name
+
+ if self.features & Object.FEATURE__LIST:
+ source += "/* esxVI_%s_CastListFromAnyType */\n" % self.name
+ source += "ESX_VI__TEMPLATE__LIST__CAST_FROM_ANY_TYPE(%s)\n\n" % self.name
+
+ # serialize
+ if self.extended_by is None:
+ if self.features & Object.FEATURE__SERIALIZE:
+ source += "/* esxVI_%s_Serialize */\n" % self.name
+ source += "ESX_VI__TEMPLATE__SERIALIZE(%s,\n" % self.name
+ source += "{\n"
+
+ source += self.generate_serialize_code()
+
+ source += "})\n\n"
+
+ if self.features & Object.FEATURE__LIST:
+ source += "/* esxVI_%s_SerializeList */\n" % self.name
+ source += "ESX_VI__TEMPLATE__LIST__SERIALIZE(%s)\n\n" % self.name
+ else:
+ if self.features & Object.FEATURE__SERIALIZE:
+ source += "/* esxVI_%s_Serialize */\n" % self.name
+ source += "ESX_VI__TEMPLATE__DYNAMIC_SERIALIZE(%s,\n" % self.name
+ source += "{\n"
+
+ for extended_by in self.extended_by:
+ source += " ESX_VI__TEMPLATE__DISPATCH__SERIALIZE(%s)\n" % extended_by
+
+ source += "},\n"
+ source += "{\n"
+
+ source += self.generate_serialize_code()
+
+ source += "})\n\n"
+
+ if self.features & Object.FEATURE__LIST:
+ source += "/* esxVI_%s_SerializeList */\n" % self.name
+ source += "ESX_VI__TEMPLATE__LIST__SERIALIZE(%s)\n\n" % self.name
+
+ # deserilaize
+ if self.features & Object.FEATURE__DESERIALIZE:
+ source += "/* esxVI_%s_Deserialize */\n" % self.name
+ source += "ESX_VI__TEMPLATE__DESERIALIZE(%s,\n" % self.name
+ source += "{\n"
+
+ source += self.generate_deserialize_code()
+
+ source += "})\n\n"
+
+ if self.features & Object.FEATURE__LIST:
+ source += "/* esxVI_%s_DeserializeList */\n" % self.name
+ source += "ESX_VI__TEMPLATE__LIST__DESERIALIZE(%s)\n\n" % self.name
+
+ source += "\n\n"
+
+ return source
+
+
+
+
+
+
+
+
+class Enum:
+ FEATURE__ANY_TYPE = (1 << 1)
+ FEATURE__SERIALIZE = (1 << 2)
+ FEATURE__DESERIALIZE = (1 << 3)
+
+
+ def __init__(self, name, values, features = 0):
+ self.name = name
+ self.values = values
+ self.features = features | Enum.FEATURE__SERIALIZE | Enum.FEATURE__DESERIALIZE
+
+ def generate_typedef(self):
+ return "typedef enum _esxVI_%s esxVI_%s;\n" % (self.name, self.name)
+
+ def generate_typeenum(self):
+ return " esxVI_Type_%s,\n" % self.name
+
+ def generate_typetostring(self):
+ string = " case esxVI_Type_%s:\n" % self.name
+ string += " return \"%s\";\n\n" % self.name
+
+ return string
+
+ def generate_typefromstring(self):
+ string = " else if (STREQ(type, \"%s\")) {\n" % self.name
+ string += " return esxVI_Type_%s;\n" % self.name
+ string += " }\n"
+
+ return string
+
+ def generate_header(self):
+ header = "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"
+ header += " * VI Enum: %s\n" % self.name
+ header += " */\n\n"
+
+ # enum
+ header += "enum _esxVI_%s {\n" % self.name
+ header += " esxVI_%s_Undefined = 0,\n" % self.name
+
+ for value in self.values:
+ header += " esxVI_%s_%s,\n" % (self.name, capitalize_first(value))
+
+ header += "};\n\n"
+
+ # functions
+ if self.features & Enum.FEATURE__ANY_TYPE:
+ header += "int esxVI_%s_CastFromAnyType(esxVI_AnyType *anyType, esxVI_%s *item);\n" % (self.name, self.name)
+
+ if self.features & Enum.FEATURE__SERIALIZE:
+ header += "int esxVI_%s_Serialize(esxVI_%s item, const char *element, virBufferPtr output);\n" % (self.name, self.name)
+
+ if self.features & Enum.FEATURE__DESERIALIZE:
+ header += "int esxVI_%s_Deserialize(xmlNodePtr node, esxVI_%s *item);\n" % (self.name, self.name)
+
+ header += "\n\n\n"
+
+ return header
+
+ def generate_source(self):
+ source = "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"
+ source += " * VI Enum: %s\n" % self.name
+ source += " */\n\n"
+
+ source += "static const esxVI_Enumeration _esxVI_%s_Enumeration = {\n" % self.name
+ source += " esxVI_Type_%s, {\n" % self.name
+
+ for value in self.values:
+ source += " { \"%s\", esxVI_%s_%s },\n" % (value, self.name, capitalize_first(value))
+
+ source += " { NULL, -1 },\n"
+ source += " },\n"
+ source += "};\n\n"
+
+ # functions
+ if self.features & Enum.FEATURE__ANY_TYPE:
+ source += "/* esxVI_%s_CastFromAnyType */\n" % self.name
+ source += "ESX_VI__TEMPLATE__ENUMERATION__CAST_FROM_ANY_TYPE(%s)\n\n" % self.name
+
+ if self.features & Enum.FEATURE__SERIALIZE:
+ source += "/* esxVI_%s_Serialize */\n" % self.name
+ source += "ESX_VI__TEMPLATE__ENUMERATION__SERIALIZE(%s)\n\n" % self.name
+
+ if self.features & Enum.FEATURE__DESERIALIZE:
+ source += "/* esxVI_%s_Deserialize */\n" % self.name
+ source += "ESX_VI__TEMPLATE__ENUMERATION__DESERIALIZE(%s)\n\n" % self.name
+
+ source += "\n\n"
+
+ return source
+
+
+
+
+
+def report_error(message):
+ print "error: " + message
+ sys.exit(1)
+
+
+
+def usage():
+ print "%s <input-filename> <output-directory>" % sys.argv[0]
+ sys.exit(0)
+
+
+
+def capitalize_first(string):
+ return string[:1].upper() + string[1:]
+
+
+
+def parse_object(block):
+ # expected format: object <name> [extends <name>]
+ header_items = block[0][1].split()
+
+ if len(header_items) < 2:
+ report_error("line %d: invalid block header" % (number))
+
+ assert header_items[0] == "object"
+
+ name = header_items[1]
+ extends = None
+
+ if len(header_items) > 2:
+ if header_items[2] != "extends":
+ report_error("line %d: invalid block header" % (number))
+ else:
+ extends = header_items[3]
+
+ properties = []
+
+ for line in block[1:]:
+ # expected format: <type> <name> <occurrence>
+ items = line[1].split()
+
+ if len(items) != 3:
+ report_error("line %d: invalid property" % line[0])
+
+ if items[2] not in Property.valid_occurrences:
+ report_error("line %d: invalid occurrence" % line[0])
+
+ properties.append(Property(type = items[0], name = items[1],
+ occurrence = items[2]))
+
+ return Object(name = name, extends = extends, properties = properties)
+
+
+
+def parse_enum(block):
+ # expected format: enum <name>
+ header_items = block[0][1].split()
+
+ if len(header_items) < 2:
+ report_error("line %d: invalid block header" % (number))
+
+ assert header_items[0] == "enum"
+
+ name = header_items[1]
+
+ values = []
+
+ for line in block[1:]:
+ # expected format: <value>
+ values.append(line[1])
+
+ return Enum(name = name, values = values)
+
+
+
+def inherit_features(obj):
+ if obj.extended_by is not None:
+ for extended_by in obj.extended_by:
+ objects_by_name[extended_by].features |= obj.features
+
+ if obj.extends is not None:
+ objects_by_name[obj.extends].features |= obj.features
+
+ if obj.extended_by is not None:
+ for extended_by in obj.extended_by:
+ inherit_features(objects_by_name[extended_by])
+
+
+
+def is_known_type(type):
+ return type in predefined_objects or \
+ type in predefined_enums or \
+ type in objects_by_name or \
+ type in enums_by_name
+
+
+
+def open_and_print(filename):
+ if filename.startswith("./"):
+ print " GEN " + filename[2:]
+ else:
+ print " GEN " + filename
+
+ return open(filename, "wb")
+
+
+
+
+
+
+
+
+
+
+predefined_enums = ["Boolean"]
+
+predefined_objects = ["AnyType",
+ "Int",
+ "Long",
+ "String",
+ "DateTime",
+ "ManagedObjectReference"]
+
+
+additional_enum_features = { "ManagedEntityStatus" : Enum.FEATURE__ANY_TYPE,
+ "TaskInfoState" : Enum.FEATURE__ANY_TYPE,
+ "VirtualMachinePowerState" : Enum.FEATURE__ANY_TYPE }
+
+
+additional_object_features = { "Event" : Object.FEATURE__LIST,
+ "HostCpuIdInfo" : Object.FEATURE__ANY_TYPE | Object.FEATURE__LIST,
+ "ManagedObjectReference" : Object.FEATURE__ANY_TYPE,
+ "ObjectContent" : Object.FEATURE__DEEP_COPY | Object.FEATURE__LIST,
+ "PerfCounterInfo" : Object.FEATURE__LIST,
+ "PerfEntityMetric" : Object.FEATURE__LIST,
+ "PerfQuerySpec" : Object.FEATURE__LIST,
+ "PerfMetricIntSeries" : Object.FEATURE__DYNAMIC_CAST,
+ "PropertyFilterSpec" : Object.FEATURE__LIST,
+ "ResourcePoolResourceUsage" : Object.FEATURE__ANY_TYPE,
+ "SelectionSpec" : Object.FEATURE__DYNAMIC_CAST,
+ "SharesInfo" : Object.FEATURE__ANY_TYPE,
+ "TaskInfo" : Object.FEATURE__ANY_TYPE | Object.FEATURE__LIST,
+ "UserSession" : Object.FEATURE__ANY_TYPE,
+ "VirtualMachineQuestionInfo" : Object.FEATURE__ANY_TYPE }
+
+
+removed_object_features = { "DynamicProperty" : Object.FEATURE__SERIALIZE,
+ "ObjectContent" : Object.FEATURE__SERIALIZE,
+ "ObjectUpdate" : Object.FEATURE__SERIALIZE,
+ "PropertyChange" : Object.FEATURE__SERIALIZE,
+ "PropertyFilterUpdate" : Object.FEATURE__SERIALIZE,
+ "TaskInfo" : Object.FEATURE__SERIALIZE,
+ "UpdateSet" : Object.FEATURE__SERIALIZE,
+ "VirtualMachineConfigInfo" : Object.FEATURE__SERIALIZE }
+
+
+
+
+if "srcdir" in os.environ:
+ input_filename = os.path.join(os.environ["srcdir"], "esx/esx_vi_generator.input")
+ output_dirname = os.path.join(os.environ["srcdir"], "esx")
+else:
+ input_filename = os.path.join(os.getcwd(), "esx_vi_generator.input")
+ output_dirname = os.getcwd()
+
+
+
+typedef = open_and_print(os.path.join(output_dirname, "esx_vi_types.generated.typedef"))
+typeenum = open_and_print(os.path.join(output_dirname, "esx_vi_types.generated.typeenum"))
+typetostring = open_and_print(os.path.join(output_dirname, "esx_vi_types.generated.typetostring"))
+typefromstring = open_and_print(os.path.join(output_dirname, "esx_vi_types.generated.typefromstring"))
+header = open_and_print(os.path.join(output_dirname, "esx_vi_types.generated.h"))
+source = open_and_print(os.path.join(output_dirname, "esx_vi_types.generated.c"))
+
+
+
+number = 0
+objects_by_name = {}
+enums_by_name = {}
+block = None
+
+
+
+for line in file(input_filename, "rb").readlines():
+ number += 1
+
+ if "#" in line:
+ line = line[:line.index("#")]
+
+ line = line.lstrip().rstrip()
+
+ if len(line) < 1:
+ continue
+
+ if line.startswith("object") or line.startswith("enum"):
+ if block is not None:
+ report_error("line %d: nested block found" % (number))
+ else:
+ block = []
+
+ if block is not None:
+ if line == "end":
+ if block[0][1].startswith("object"):
+ obj = parse_object(block)
+ objects_by_name[obj.name] = obj
+ else:
+ enum = parse_enum(block)
+ enums_by_name[enum.name] = enum
+
+ block = None
+ else:
+ block.append((number, line))
+
+
+
+for enum in enums_by_name.values():
+ # apply additional features
+ if enum.name in additional_enum_features:
+ enum.features |= additional_enum_features[enum.name]
+
+
+
+for obj in objects_by_name.values():
+ for property in obj.properties:
+ if property.occurrence != Property.OCCURRENCE__IGNORED and \
+ not is_known_type(property.type):
+ report_error("object '%s' contains unknown property type '%s'" % (obj.name, property.type))
+
+ if obj.extends is not None:
+ if not is_known_type(obj.extends):
+ report_error("object '%s' extends unknown object '%s'" % (obj.name, obj.extends))
+
+ # detect list usage
+ for property in obj.properties:
+ if (property.occurrence == Property.OCCURRENCE__REQUIRED_LIST or \
+ property.occurrence == Property.OCCURRENCE__OPTIONAL_LIST) and \
+ property.type not in predefined_objects:
+ objects_by_name[property.type].features |= Object.FEATURE__LIST
+
+ # apply/remove additional features
+ if obj.name in additional_object_features:
+ obj.features |= additional_object_features[obj.name]
+
+ if obj.name in removed_object_features:
+ obj.features &= ~removed_object_features[obj.name]
+
+ # spread deep copy onto properties
+ if obj.features & Object.FEATURE__DEEP_COPY:
+ for property in obj.properties:
+ if property.occurrence != Property.OCCURRENCE__IGNORED and \
+ property.type not in predefined_objects:
+ objects_by_name[property.type].features |= Object.FEATURE__DEEP_COPY
+
+ # detect extended_by relation
+ if obj.extends is not None:
+ extended_obj = objects_by_name[obj.extends]
+
+ if extended_obj.extended_by is None:
+ extended_obj.extended_by = [obj.name]
+ else:
+ extended_obj.extended_by.append(obj.name)
+
+
+
+
+
+for obj in objects_by_name.values():
+ inherit_features(obj)
+
+
+
+
+
+typedef.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
+typeenum.write("/* Generated by esx_vi_generator.py */\n\n")
+typetostring.write("/* Generated by esx_vi_generator.py */\n\n")
+typefromstring.write("/* Generated by esx_vi_generator.py */\n\n")
+header.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
+source.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
+
+
+typedef.write("/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n" +
+ " * VI Enums\n" +
+ " */\n\n")
+
+
+
+names = enums_by_name.keys()
+names.sort()
+
+
+for name in names:
+ typedef.write(enums_by_name[name].generate_typedef())
+ typeenum.write(enums_by_name[name].generate_typeenum())
+ typetostring.write(enums_by_name[name].generate_typetostring())
+ typefromstring.write(enums_by_name[name].generate_typefromstring())
+ header.write(enums_by_name[name].generate_header())
+ source.write(enums_by_name[name].generate_source())
+
+
+
+typedef.write("\n\n\n" +
+ "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n" +
+ " * VI Types\n" +
+ " */\n\n")
+
+typeenum.write("\n")
+
+typetostring.write("\n")
+
+typefromstring.write("\n")
+
+
+
+names = objects_by_name.keys()
+names.sort()
+
+
+for name in names:
+ typedef.write(objects_by_name[name].generate_typedef())
+ typeenum.write(objects_by_name[name].generate_typeenum())
+ typetostring.write(objects_by_name[name].generate_typetostring())
+ typefromstring.write(objects_by_name[name].generate_typefromstring())
+ header.write(objects_by_name[name].generate_header())
+ source.write(objects_by_name[name].generate_source())
diff --git a/src/esx/esx_vi_methods.c b/src/esx/esx_vi_methods.c
index 07cd82a..f1234ae 100644
--- a/src/esx/esx_vi_methods.c
+++ b/src/esx/esx_vi_methods.c
@@ -304,7 +304,7 @@ ESX_VI__METHOD(RetrieveProperties,
(esxVI_Context *ctx,
esxVI_PropertyFilterSpec *specSet, /* list */
esxVI_ObjectContent **objectContentList),
- List,
+ OptionalList,
{
ESX_VI__METHOD__CHECK_SERVICE()
ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(objectContentList)
@@ -344,8 +344,7 @@ ESX_VI__METHOD(PowerOnVM_Task,
virtualMachine)
},
{
- if (esxVI_ManagedObjectReference_Deserialize(response->node, task,
- "Task") < 0) {
+ if (esxVI_ManagedObjectReference_Deserialize(response->node, task) < 0) {
goto failure;
}
})
@@ -369,8 +368,7 @@ ESX_VI__METHOD(PowerOffVM_Task,
virtualMachine)
},
{
- if (esxVI_ManagedObjectReference_Deserialize(response->node, task,
- "Task") < 0) {
+ if (esxVI_ManagedObjectReference_Deserialize(response->node, task) < 0) {
goto failure;
}
})
@@ -394,8 +392,7 @@ ESX_VI__METHOD(SuspendVM_Task,
virtualMachine)
},
{
- if (esxVI_ManagedObjectReference_Deserialize(response->node, task,
- "Task") < 0) {
+ if (esxVI_ManagedObjectReference_Deserialize(response->node, task) < 0) {
goto failure;
}
})
@@ -428,8 +425,7 @@ ESX_VI__METHOD(MigrateVM_Task,
ESX_VI__METHOD__PARAMETER__SERIALIZE(VirtualMachinePowerState, state)
},
{
- if (esxVI_ManagedObjectReference_Deserialize(response->node, task,
- "Task") < 0) {
+ if (esxVI_ManagedObjectReference_Deserialize(response->node, task) < 0) {
goto failure;
}
})
@@ -456,8 +452,7 @@ ESX_VI__METHOD(ReconfigVM_Task,
ESX_VI__METHOD__PARAMETER__SERIALIZE(VirtualMachineConfigSpec, spec)
},
{
- if (esxVI_ManagedObjectReference_Deserialize(response->node, task,
- "Task") < 0) {
+ if (esxVI_ManagedObjectReference_Deserialize(response->node, task) < 0) {
goto failure;
}
})
@@ -490,8 +485,7 @@ ESX_VI__METHOD(RegisterVM_Task,
ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, host)
},
{
- if (esxVI_ManagedObjectReference_Deserialize(response->node, task,
- "Task") < 0) {
+ if (esxVI_ManagedObjectReference_Deserialize(response->node, task) < 0) {
goto failure;
}
})
@@ -583,8 +577,8 @@ ESX_VI__METHOD(CreateFilter,
ESX_VI__METHOD__PARAMETER__SERIALIZE(Boolean, partialUpdates)
},
{
- if (esxVI_ManagedObjectReference_Deserialize(response->node, propertyFilter,
- "PropertyFilter") < 0) {
+ if (esxVI_ManagedObjectReference_Deserialize(response->node,
+ propertyFilter) < 0) {
goto failure;
}
})
@@ -684,7 +678,7 @@ ESX_VI__METHOD(ValidateMigration,
esxVI_ManagedObjectReference *pool,
esxVI_ManagedObjectReference *host,
esxVI_Event **eventList),
- List,
+ OptionalList,
{
ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(eventList)
},
@@ -736,10 +730,8 @@ ESX_VI__METHOD(FindByIp,
ESX_VI__METHOD__PARAMETER__SERIALIZE(Boolean, vmSearch)
},
{
- if (esxVI_ManagedObjectReference_Deserialize
- (response->node, managedObjectReference,
- vmSearch == esxVI_Boolean_True ? "VirtualMachine"
- : "HostSystem") < 0) {
+ if (esxVI_ManagedObjectReference_Deserialize(response->node,
+ managedObjectReference) < 0) {
goto failure;
}
})
@@ -771,10 +763,8 @@ ESX_VI__METHOD(FindByUuid,
ESX_VI__METHOD__PARAMETER__SERIALIZE(Boolean, vmSearch)
},
{
- if (esxVI_ManagedObjectReference_Deserialize
- (response->node, managedObjectReference,
- vmSearch == esxVI_Boolean_True ? "VirtualMachine"
- : "HostSystem") < 0) {
+ if (esxVI_ManagedObjectReference_Deserialize(response->node,
+ managedObjectReference) < 0) {
goto failure;
}
})
@@ -789,7 +779,7 @@ ESX_VI__METHOD(QueryAvailablePerfMetric,
esxVI_DateTime *endTime,
esxVI_Int *intervalId,
esxVI_PerfMetricId **perfMetricIdList),
- List,
+ OptionalList,
{
ESX_VI__METHOD__CHECK_SERVICE()
ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(perfMetricIdList)
@@ -820,7 +810,7 @@ ESX_VI__METHOD(QueryPerfCounter,
(esxVI_Context *ctx,
esxVI_Int *counterId, /* list */
esxVI_PerfCounterInfo **perfCounterInfoList),
- List,
+ OptionalList,
{
ESX_VI__METHOD__CHECK_SERVICE()
ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(perfCounterInfoList)
@@ -848,7 +838,7 @@ ESX_VI__METHOD(QueryPerf,
(esxVI_Context *ctx,
esxVI_PerfQuerySpec *querySpec, /* list */
esxVI_PerfEntityMetric **perfEntityMetricList),
- List,
+ OptionalList,
{
ESX_VI__METHOD__CHECK_SERVICE()
ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(perfEntityMetricList)
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index 87a13cb..6f257b2 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -64,11 +64,17 @@
-#define ESX_VI__TEMPLATE__ALLOC(_type) \
+#define ESX_VI__TEMPLATE__ALLOC(__type) \
int \
- esxVI_##_type##_Alloc(esxVI_##_type **ptrptr) \
+ esxVI_##__type##_Alloc(esxVI_##__type **ptrptr) \
{ \
- return esxVI_Alloc((void **)ptrptr, sizeof(esxVI_##_type)); \
+ if (esxVI_Alloc((void **)ptrptr, sizeof (esxVI_##__type)) < 0) { \
+ return -1; \
+ } \
+ \
+ (*ptrptr)->_type = esxVI_Type_##__type; \
+ \
+ return 0; \
}
@@ -92,11 +98,18 @@
-#define ESX_VI__TEMPLATE__VALIDATE(_type, _require) \
+#define ESX_VI__TEMPLATE__VALIDATE(__type, _require) \
int \
- esxVI_##_type##_Validate(esxVI_##_type *item) \
+ esxVI_##__type##_Validate(esxVI_##__type *item) \
{ \
- const char *type_name = #_type; \
+ const char *type_name = esxVI_Type_ToString(esxVI_Type_##__type); \
+ \
+ if (item->_type <= esxVI_Type_Undefined || \
+ item->_type >= esxVI_Type_Other) { \
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
+ "%s object has invalid dynamic type", type_name); \
+ return -1; \
+ } \
\
_require \
\
@@ -105,11 +118,31 @@
-#define ESX_VI__TEMPLATE__VALIDATE_NOOP(_type) \
+#define ESX_VI__TEMPLATE__DEEP_COPY(_type, _deep_copy) \
int \
- esxVI_##_type##_Validate(esxVI_##_type *item ATTRIBUTE_UNUSED) \
+ esxVI_##_type##_DeepCopy(esxVI_##_type **dest, esxVI_##_type *src) \
{ \
+ if (dest == NULL || *dest != NULL) { \
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument"); \
+ return -1; \
+ } \
+ \
+ if (src == NULL) { \
+ return 0; \
+ } \
+ \
+ if (esxVI_##_type##_Alloc(dest) < 0) { \
+ goto failure; \
+ } \
+ \
+ _deep_copy \
+ \
return 0; \
+ \
+ failure: \
+ esxVI_##_type##_Free(dest); \
+ \
+ return -1; \
}
@@ -184,19 +217,20 @@
return -1; \
} \
\
- if (STRNEQ(anyType->other, #_type)) { \
+ if (anyType->type != esxVI_Type_##_type) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
"Expecting type '%s' but found '%s'", \
- #_type, anyType->other); \
+ esxVI_Type_ToString(esxVI_Type_##_type), \
+ anyType->other); \
return -1; \
} \
\
- return esxVI_##_type##_Deserialize(anyType->_node, ptrptr); \
+ return esxVI_##_type##_Deserialize(anyType->node, ptrptr); \
}
-#define ESX_VI__TEMPLATE__SERIALIZE_EXTRA(_type, _type_string, _serialize) \
+#define ESX_VI__TEMPLATE__SERIALIZE_EXTRA(_type, _extra, _serialize) \
int \
esxVI_##_type##_Serialize(esxVI_##_type *item, \
const char *element, virBufferPtr output) \
@@ -210,11 +244,14 @@
return 0; \
} \
\
+ _extra \
+ \
if (esxVI_##_type##_Validate(item) < 0) { \
return -1; \
} \
\
- ESV_VI__XML_TAG__OPEN(output, element, _type_string); \
+ ESV_VI__XML_TAG__OPEN(output, element, \
+ esxVI_Type_ToString(esxVI_Type_##_type)); \
\
_serialize \
\
@@ -226,7 +263,7 @@
#define ESX_VI__TEMPLATE__SERIALIZE(_type, _serialize) \
- ESX_VI__TEMPLATE__SERIALIZE_EXTRA(_type, #_type, _serialize)
+ ESX_VI__TEMPLATE__SERIALIZE_EXTRA(_type, /* nothing */, _serialize)
@@ -328,6 +365,31 @@
+/*
+ * Macros for property handling to be used as part of other macros
+ */
+
+#define ESX_VI__TEMPLATE__PROPERTY__DEEP_COPY(_type, _name) \
+ if (esxVI_##_type##_DeepCopy(&(*dest)->_name, src->_name) < 0) { \
+ goto failure; \
+ }
+
+
+
+#define ESX_VI__TEMPLATE__PROPERTY__DEEP_COPY_LIST(_type, _name) \
+ if (esxVI_##_type##_DeepCopyList(&(*dest)->_name, src->_name) < 0) { \
+ goto failure; \
+ }
+
+
+
+#define ESX_VI__TEMPLATE__PROPERTY__DEEP_COPY_VALUE(_type, _name) \
+ if (esxVI_##_type##_DeepCopyValue(&(*dest)->_name, src->_name) < 0) { \
+ goto failure; \
+ }
+
+
+
#define ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(_type, _name) \
if (esxVI_##_type##_Serialize(item->_name, #_name, output) < 0) { \
return -1; \
@@ -360,23 +422,17 @@
-#define ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(_type, _name) \
+#define ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_IGNORE(_name) \
if (xmlStrEqual(childNode->name, BAD_CAST #_name)) { \
- if (esxVI_##_type##_DeserializeValue(childNode, \
- &(*ptrptr)->_name) < 0) { \
- goto failure; \
- } \
- \
continue; \
}
-#define ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(_type, _expected, \
- _name) \
+#define ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(_type, _name) \
if (xmlStrEqual(childNode->name, BAD_CAST #_name)) { \
- if (esxVI_##_type##_Deserialize(childNode, &(*ptrptr)->_name, \
- _expected) < 0) { \
+ if (esxVI_##_type##_DeserializeValue(childNode, \
+ &(*ptrptr)->_name) < 0) { \
goto failure; \
} \
\
@@ -385,13 +441,6 @@
-#define ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_NOOP(_name) \
- if (xmlStrEqual(childNode->name, BAD_CAST #_name)) { \
- continue; \
- }
-
-
-
#define ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_LIST(_type, _name) \
if (xmlStrEqual(childNode->name, BAD_CAST #_name)) { \
esxVI_##_type *_name##Item = NULL; \
@@ -427,6 +476,10 @@
+/*
+ * Macros to implement enumerations
+ */
+
#define ESX_VI__TEMPLATE__ENUMERATION__CAST_FROM_ANY_TYPE(_type) \
int \
esxVI_##_type##_CastFromAnyType(esxVI_AnyType *anyType, \
@@ -459,20 +512,102 @@
+/*
+ * Macros to implement dynamic dispatched functions
+ */
+
+#define ESX_VI__TEMPLATE__DISPATCH(__type, _dispatch, _error_return) \
+ switch (item->_type) { \
+ _dispatch \
+ \
+ case esxVI_Type_##__type: \
+ break; \
+ \
+ default: \
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
+ "Call to %s for unexpected type '%s'", __FUNCTION__, \
+ esxVI_Type_ToString(item->_type)); \
+ return _error_return; \
+ }
+
+
+
+#define ESX_VI__TEMPLATE__DISPATCH__FREE(_type) \
+ case esxVI_Type_##_type: \
+ esxVI_##_type##_Free((esxVI_##_type **)ptrptr); \
+ return;
+
+
+
+#define ESX_VI__TEMPLATE__DISPATCH__DEEP_COPY(_type) \
+ case esxVI_Type_##_type: \
+ return esxVI_##_type##_DeepCopy((esxVI_##_type **)dst, \
+ (esxVI_##_type *)src);
+
+
+
+#define ESX_VI__TEMPLATE__DISPATCH__SERIALIZE(_type) \
+ case esxVI_Type_##_type: \
+ return esxVI_##_type##_Serialize((esxVI_##_type *)item, element, \
+ output);
+
+
+
+#define ESX_VI__TEMPLATE__DYNAMIC_FREE(__type, _dispatch, _body) \
+ ESX_VI__TEMPLATE__FREE(__type, \
+ ESX_VI__TEMPLATE__DISPATCH(__type, _dispatch, /* nothing */) \
+ _body)
+
+
+
+#define ESX_VI__TEMPLATE__DYNAMIC_CAST(__type, _accept) \
+ esxVI_##__type * \
+ esxVI_##__type##_DynamicCast(void *item) \
+ { \
+ if (item == NULL) { \
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument"); \
+ return NULL; \
+ } \
+ \
+ _accept \
+ \
+ return NULL; \
+ }
+
+
+
+#define ESX_VI__TEMPLATE__DYNAMIC_CAST__ACCEPT(__type) \
+ if (((esxVI_Object *)item)->_type == esxVI_Type_##__type) { \
+ return item; \
+ }
+
+
+
+#define ESX_VI__TEMPLATE__DYNAMIC_SERIALIZE(__type, _dispatch, _serialize) \
+ ESX_VI__TEMPLATE__SERIALIZE_EXTRA(__type, \
+ ESX_VI__TEMPLATE__DISPATCH(__type, _dispatch, -1), \
+ _serialize)
+
+
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* XSI: Type
*/
const char *
-esxVI_Type_Name(esxVI_Type type)
+esxVI_Type_ToString(esxVI_Type type)
{
switch (type) {
+ default:
case esxVI_Type_Undefined:
- return "undefined";
+ return "<undefined>";
case esxVI_Type_Boolean:
return "xsd:boolean";
+ case esxVI_Type_AnyType:
+ return "xsd:anyType";
+
case esxVI_Type_String:
return "xsd:string";
@@ -485,14 +620,53 @@ esxVI_Type_Name(esxVI_Type type)
case esxVI_Type_Long:
return "xsd:long";
- case esxVI_Type_Other:
- return "other";
+ case esxVI_Type_DateTime:
+ return "xsd:dateTime";
- default:
- return "unknown";
+ case esxVI_Type_Fault:
+ return "Fault";
+
+ case esxVI_Type_ManagedObjectReference:
+ return "ManagedObjectReference";
+
+#include "esx_vi_types.generated.typetostring"
+
+ case esxVI_Type_Other:
+ return "<other>";
}
}
+esxVI_Type
+esxVI_Type_FromString(const char *type)
+{
+ if (type == NULL || STREQ(type, "<undefined>")) {
+ return esxVI_Type_Undefined;
+ } else if (STREQ(type, "xsd:boolean")) {
+ return esxVI_Type_Boolean;
+ } else if (STREQ(type, "xsd:anyType")) {
+ return esxVI_Type_AnyType;
+ } else if (STREQ(type, "xsd:string")) {
+ return esxVI_Type_String;
+ } else if (STREQ(type, "xsd:short")) {
+ return esxVI_Type_Short;
+ } else if (STREQ(type, "xsd:int")) {
+ return esxVI_Type_Int;
+ } else if (STREQ(type, "xsd:long")) {
+ return esxVI_Type_Long;
+ } else if (STREQ(type, "xsd:dateTime")) {
+ return esxVI_Type_DateTime;
+ } else if (STREQ(type, "Fault")) {
+ return esxVI_Type_Fault;
+ } else if (STREQ(type, "ManagedObjectReference")) {
+ return esxVI_Type_ManagedObjectReference;
+ }
+
+#include "esx_vi_types.generated.typefromstring"
+
+ else {
+ return esxVI_Type_Other;
+ }
+}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
@@ -500,7 +674,7 @@ esxVI_Type_Name(esxVI_Type type)
*/
static const esxVI_Enumeration _esxVI_Boolean_Enumeration = {
- "xsd:boolean", {
+ esxVI_Type_Boolean, {
{ "true", esxVI_Boolean_True },
{ "false", esxVI_Boolean_False },
{ NULL, -1 },
@@ -525,7 +699,7 @@ ESX_VI__TEMPLATE__ALLOC(AnyType);
/* esxVI_AnyType_Free */
ESX_VI__TEMPLATE__FREE(AnyType,
{
- xmlFreeNode(item->_node);
+ xmlFreeNode(item->node);
VIR_FREE(item->other);
VIR_FREE(item->value);
});
@@ -536,9 +710,9 @@ esxVI_AnyType_ExpectType(esxVI_AnyType *anyType, esxVI_Type type)
if (anyType->type != type) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
"Expecting type '%s' but found '%s'",
- esxVI_Type_Name(type),
+ esxVI_Type_ToString(type),
anyType->type != esxVI_Type_Other
- ? esxVI_Type_Name(anyType->type)
+ ? esxVI_Type_ToString(anyType->type)
: anyType->other);
return -1;
}
@@ -562,9 +736,10 @@ esxVI_AnyType_DeepCopy(esxVI_AnyType **dest, esxVI_AnyType *src)
goto failure;
}
- (*dest)->_node = xmlCopyNode(src->_node, 1);
+ (*dest)->_type = src->_type;
+ (*dest)->node = xmlCopyNode(src->node, 1);
- if ((*dest)->_node == NULL) {
+ if ((*dest)->node == NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Could not copy an XML node");
goto failure;
}
@@ -612,7 +787,7 @@ esxVI_AnyType_DeepCopy(esxVI_AnyType **dest, esxVI_AnyType *src)
int
esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType)
{
- long long number;
+ long long int number;
if (anyType == NULL || *anyType != NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
@@ -623,9 +798,9 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType)
return -1;
}
- (*anyType)->_node = xmlCopyNode(node, 1);
+ (*anyType)->node = xmlCopyNode(node, 1);
- if ((*anyType)->_node == NULL) {
+ if ((*anyType)->node == NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Could not copy an XML node");
goto failure;
}
@@ -641,6 +816,15 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType)
goto failure;
}
+ (*anyType)->type = esxVI_Type_FromString((*anyType)->other);
+
+ if ((*anyType)->type == esxVI_Type_Undefined) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
+ "Unknown value '%s' for AnyType 'type' property",
+ (*anyType)->other);
+ goto failure;
+ }
+
(*anyType)->value =
(char *)xmlNodeListGetString(node->doc, node->children, 1);
@@ -669,13 +853,11 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType)
goto failure; \
} \
\
- (*anyType)->type = esxVI_Type_##_type; \
(*anyType)->_name = number; \
} while (0)
- if (STREQ((*anyType)->other, "xsd:boolean")) {
- (*anyType)->type = esxVI_Type_Boolean;
-
+ switch ((*anyType)->type) {
+ case esxVI_Type_Boolean:
if (STREQ((*anyType)->value, "true")) {
(*anyType)->boolean = esxVI_Boolean_True;
} else if (STREQ((*anyType)->value, "false")) {
@@ -686,15 +868,27 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType)
(*anyType)->value);
goto failure;
}
- } else if (STREQ((*anyType)->other, "xsd:string")) {
- (*anyType)->type = esxVI_Type_String;
+
+ break;
+
+ case esxVI_Type_String:
(*anyType)->string = (*anyType)->value;
- } else if (STREQ((*anyType)->other, "xsd:short")) {
+ break;
+
+ case esxVI_Type_Short:
_DESERIALIZE_NUMBER(Short, "xsd:short", int16, INT16_MIN, INT16_MAX);
- } else if (STREQ((*anyType)->other, "xsd:int")) {
+ break;
+
+ case esxVI_Type_Int:
_DESERIALIZE_NUMBER(Int, "xsd:int", int32, INT32_MIN, INT32_MAX);
- } else if (STREQ((*anyType)->other, "xsd:long")) {
+ break;
+
+ case esxVI_Type_Long:
_DESERIALIZE_NUMBER(Long, "xsd:long", int64, INT64_MIN, INT64_MAX);
+ break;
+
+ default:
+ break;
}
#undef _DESERIALIZE_NUMBER
@@ -724,6 +918,12 @@ ESX_VI__TEMPLATE__FREE(String,
VIR_FREE(item->value);
});
+/* esxVI_String_Validate */
+ESX_VI__TEMPLATE__VALIDATE(String,
+{
+ ESX_VI__TEMPLATE__PROPERTY__REQUIRE(value)
+})
+
/* esxVI_String_AppendToList */
ESX_VI__TEMPLATE__LIST__APPEND(String);
@@ -782,30 +982,11 @@ esxVI_String_AppendValueListToList(esxVI_String **stringList,
return -1;
}
-int
-esxVI_String_DeepCopy(esxVI_String **dest, esxVI_String *src)
+/* esxVI_String_DeepCopy */
+ESX_VI__TEMPLATE__DEEP_COPY(String,
{
- if (dest == NULL || *dest != NULL) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
- return -1;
- }
-
- if (src == NULL) {
- return 0;
- }
-
- if (esxVI_String_Alloc(dest) < 0 ||
- esxVI_String_DeepCopyValue(&(*dest)->value, src->value)) {
- goto failure;
- }
-
- return 0;
-
- failure:
- esxVI_String_Free(dest);
-
- return -1;
-}
+ ESX_VI__TEMPLATE__PROPERTY__DEEP_COPY_VALUE(String, value)
+})
/* esxVI_String_DeepCopyList */
ESX_VI__TEMPLATE__LIST__DEEP_COPY(String);
@@ -865,37 +1046,11 @@ esxVI_String_SerializeValue(const char *value, const char *element,
return 0;
}
-int
-esxVI_String_Deserialize(xmlNodePtr node, esxVI_String **string)
+/* esxVI_String_Deserialize */
+ESX_VI__TEMPLATE__DESERIALIZE(String,
{
- if (string == NULL || *string != NULL) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
- return -1;
- }
-
- if (esxVI_String_Alloc(string) < 0) {
- return -1;
- }
-
- (*string)->value =
- (char *)xmlNodeListGetString(node->doc, node->children, 1);
-
- if ((*string)->value == NULL) {
- (*string)->value = strdup("");
-
- if ((*string)->value == NULL) {
- virReportOOMError();
- goto failure;
- }
- }
-
- return 0;
-
- failure:
- esxVI_String_Free(string);
-
- return -1;
-}
+ ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, value)
+})
/* esxVI_String_DeserializeList */
ESX_VI__TEMPLATE__LIST__DESERIALIZE(String);
@@ -938,39 +1093,21 @@ ESX_VI__TEMPLATE__FREE(Int,
});
/* esxVI_Int_Validate */
-ESX_VI__TEMPLATE__VALIDATE_NOOP(Int);
+ESX_VI__TEMPLATE__VALIDATE(Int,
+{
+})
/* esxVI_Int_AppendToList */
ESX_VI__TEMPLATE__LIST__APPEND(Int);
-int
-esxVI_Int_DeepCopy(esxVI_Int **dest, esxVI_Int *src)
+/* esxVI_Int_DeepCopy */
+ESX_VI__TEMPLATE__DEEP_COPY(Int,
{
- if (dest == NULL || *dest != NULL) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
- return -1;
- }
-
- if (src == NULL) {
- return 0;
- }
-
- if (esxVI_Int_Alloc(dest) < 0) {
- goto failure;
- }
-
(*dest)->value = src->value;
-
- return 0;
-
- failure:
- esxVI_Int_Free(dest);
-
- return -1;
-}
+})
/* esxVI_Int_Serialize */
-ESX_VI__TEMPLATE__SERIALIZE_EXTRA(Int, "xsd:int",
+ESX_VI__TEMPLATE__SERIALIZE(Int,
{
virBufferVSprintf(output, "%d", (int)item->value);
});
@@ -997,13 +1134,15 @@ ESX_VI__TEMPLATE__FREE(Long,
});
/* esxVI_Long_Validate */
-ESX_VI__TEMPLATE__VALIDATE_NOOP(Long);
+ESX_VI__TEMPLATE__VALIDATE(Long,
+{
+})
/* esxVI_Long_AppendToList */
ESX_VI__TEMPLATE__LIST__APPEND(Long);
/* esxVI_Long_Serialize */
-ESX_VI__TEMPLATE__SERIALIZE_EXTRA(Long, "xsd:long",
+ESX_VI__TEMPLATE__SERIALIZE(Long,
{
virBufferVSprintf(output, "%lld", (long long int)item->value);
});
@@ -1036,7 +1175,7 @@ ESX_VI__TEMPLATE__VALIDATE(DateTime,
});
/* esxVI_DateTime_Serialize */
-ESX_VI__TEMPLATE__SERIALIZE_EXTRA(DateTime, "xsd:dateTime",
+ESX_VI__TEMPLATE__SERIALIZE(DateTime,
{
virBufferAdd(output, item->value, -1);
});
@@ -1074,184 +1213,6 @@ esxVI_DateTime_Deserialize(xmlNodePtr node, esxVI_DateTime **dateTime)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Enum: ManagedEntityStatus
- */
-
-static const esxVI_Enumeration _esxVI_ManagedEntityStatus_Enumeration = {
- "ManagedEntityStatus", {
- { "gray", esxVI_ManagedEntityStatus_Gray },
- { "green", esxVI_ManagedEntityStatus_Green },
- { "yellow", esxVI_ManagedEntityStatus_Yellow },
- { "red", esxVI_ManagedEntityStatus_Red },
- { NULL, -1 },
- },
-};
-
-/* esxVI_ManagedEntityStatus_CastFromAnyType */
-ESX_VI__TEMPLATE__ENUMERATION__CAST_FROM_ANY_TYPE(ManagedEntityStatus);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Enum: ObjectUpdateKind
- */
-
-static const esxVI_Enumeration _esxVI_ObjectUpdateKind_Enumeration = {
- "ObjectUpdateKind", {
- { "enter", esxVI_ObjectUpdateKind_Enter },
- { "leave", esxVI_ObjectUpdateKind_Leave },
- { "modify", esxVI_ObjectUpdateKind_Modify },
- { NULL, -1 },
- },
-};
-
-/* esxVI_ObjectUpdateKind_Deserialize */
-ESX_VI__TEMPLATE__ENUMERATION__DESERIALIZE(ObjectUpdateKind);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Enum: PerfSummaryType
- */
-
-static const esxVI_Enumeration _esxVI_PerfSummaryType_Enumeration = {
- "PerfSummaryType", {
- { "average", esxVI_PerfSummaryType_Average },
- { "latest", esxVI_PerfSummaryType_Latest },
- { "maximum", esxVI_PerfSummaryType_Maximum },
- { "minimum", esxVI_PerfSummaryType_Minimum },
- { "none", esxVI_PerfSummaryType_None },
- { "summation", esxVI_PerfSummaryType_Summation },
- { NULL, -1 },
- },
-};
-
-/* esxVI_PerfSummaryType_Deserialize */
-ESX_VI__TEMPLATE__ENUMERATION__DESERIALIZE(PerfSummaryType);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Enum: PerfStatsType
- */
-
-static const esxVI_Enumeration _esxVI_PerfStatsType_Enumeration = {
- "PerfStatsType", {
- { "absolute", esxVI_PerfStatsType_Absolute },
- { "delta", esxVI_PerfStatsType_Delta },
- { "rate", esxVI_PerfStatsType_Rate },
- { NULL, -1 },
- },
-};
-
-/* esxVI_PerfStatsType_Deserialize */
-ESX_VI__TEMPLATE__ENUMERATION__DESERIALIZE(PerfStatsType);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Enum: PropertyChangeOp
- */
-
-static const esxVI_Enumeration _esxVI_PropertyChangeOp_Enumeration = {
- "PropertyChangeOp", {
- { "add", esxVI_PropertyChangeOp_Add },
- { "remove", esxVI_PropertyChangeOp_Remove },
- { "assign", esxVI_PropertyChangeOp_Assign },
- { "indirectRemove", esxVI_PropertyChangeOp_IndirectRemove },
- { NULL, -1 },
- },
-};
-
-/* esxVI_PropertyChangeOp_Deserialize */
-ESX_VI__TEMPLATE__ENUMERATION__DESERIALIZE(PropertyChangeOp);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Enum: SharesLevel
- */
-
-static const esxVI_Enumeration _esxVI_SharesLevel_Enumeration = {
- "SharesLevel", {
- { "custom", esxVI_SharesLevel_Custom },
- { "high", esxVI_SharesLevel_High },
- { "low", esxVI_SharesLevel_Low },
- { "normal", esxVI_SharesLevel_Normal },
- { NULL, -1 },
- },
-};
-
-/* esxVI_SharesLevel_Serialize */
-ESX_VI__TEMPLATE__ENUMERATION__SERIALIZE(SharesLevel);
-
-/* esxVI_SharesLevel_Deserialize */
-ESX_VI__TEMPLATE__ENUMERATION__DESERIALIZE(SharesLevel);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Enum: TaskInfoState
- */
-
-static const esxVI_Enumeration _esxVI_TaskInfoState_Enumeration = {
- "TaskInfoState", {
- { "error", esxVI_TaskInfoState_Error },
- { "queued", esxVI_TaskInfoState_Queued },
- { "running", esxVI_TaskInfoState_Running },
- { "success", esxVI_TaskInfoState_Success },
- { NULL, -1 },
- },
-};
-
-/* esxVI_TaskInfoState_CastFromAnyType */
-ESX_VI__TEMPLATE__ENUMERATION__CAST_FROM_ANY_TYPE(TaskInfoState);
-
-/* esxVI_TaskInfoState_Deserialize */
-ESX_VI__TEMPLATE__ENUMERATION__DESERIALIZE(TaskInfoState);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Enum: VirtualMachineMovePriority
- */
-
-static const esxVI_Enumeration _esxVI_VirtualMachineMovePriority_Enumeration = {
- "VirtualMachineMovePriority", {
- { "lowPriority", esxVI_VirtualMachineMovePriority_LowPriority },
- { "highPriority", esxVI_VirtualMachineMovePriority_HighPriority },
- { "defaultPriority", esxVI_VirtualMachineMovePriority_DefaultPriority },
- { NULL, -1 },
- },
-};
-
-/* esxVI_VirtualMachineMovePriority_Serialize */
-ESX_VI__TEMPLATE__ENUMERATION__SERIALIZE(VirtualMachineMovePriority);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Enum: VirtualMachinePowerState
- */
-
-static const esxVI_Enumeration _esxVI_VirtualMachinePowerState_Enumeration = {
- "VirtualMachinePowerState", {
- { "poweredOff", esxVI_VirtualMachinePowerState_PoweredOff },
- { "poweredOn", esxVI_VirtualMachinePowerState_PoweredOn },
- { "suspended", esxVI_VirtualMachinePowerState_Suspended },
- { NULL, -1 },
- },
-};
-
-/* esxVI_VirtualMachinePowerState_CastFromAnyType */
-ESX_VI__TEMPLATE__ENUMERATION__CAST_FROM_ANY_TYPE(VirtualMachinePowerState);
-
-/* esxVI_VirtualMachinePowerState_Serialize */
-ESX_VI__TEMPLATE__ENUMERATION__SERIALIZE(VirtualMachinePowerState);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* VI Type: Fault
*/
@@ -1277,7 +1238,7 @@ ESX_VI__TEMPLATE__DESERIALIZE(Fault,
{
ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, faultcode);
ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, faultstring);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_NOOP(detail); /* FIXME */
+ ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_IGNORE(detail); /* FIXME */
});
@@ -1298,128 +1259,21 @@ ESX_VI__TEMPLATE__FREE(ManagedObjectReference,
VIR_FREE(item->value);
});
-int
-esxVI_ManagedObjectReference_DeepCopy(esxVI_ManagedObjectReference **dest,
- esxVI_ManagedObjectReference *src)
+/* esxVI_ManagedObjectReference_DeepCopy */
+ESX_VI__TEMPLATE__DEEP_COPY(ManagedObjectReference,
{
- if (dest == NULL || *dest != NULL) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
- return -1;
- }
-
- if (src == NULL) {
- return 0;
- }
-
- if (esxVI_ManagedObjectReference_Alloc(dest) < 0 ||
- esxVI_String_DeepCopyValue(&(*dest)->type, src->type) < 0 ||
- esxVI_String_DeepCopyValue(&(*dest)->value, src->value) < 0) {
- goto failure;
- }
-
- return 0;
-
- failure:
- esxVI_ManagedObjectReference_Free(dest);
-
- return -1;
-}
+ ESX_VI__TEMPLATE__PROPERTY__DEEP_COPY_VALUE(String, type)
+ ESX_VI__TEMPLATE__PROPERTY__DEEP_COPY_VALUE(String, value)
+})
/* esxVI_ManagedObjectReference_AppendToList */
ESX_VI__TEMPLATE__LIST__APPEND(ManagedObjectReference);
-int
-esxVI_ManagedObjectReference_CastFromAnyType
- (esxVI_AnyType *anyType,
- esxVI_ManagedObjectReference **managedObjectReference,
- const char *expectedType)
-{
- if (anyType == NULL || managedObjectReference == NULL ||
- *managedObjectReference != NULL) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
- return -1;
- }
-
- if (STRNEQ(anyType->other, "ManagedObjectReference")) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
- "Expecting type 'ManagedObjectReference' but found '%s'",
- anyType->other);
- return -1;
- }
-
- return esxVI_ManagedObjectReference_Deserialize(anyType->_node,
- managedObjectReference,
- expectedType);
-}
-
-int
-esxVI_ManagedObjectReference_CastListFromAnyType
- (esxVI_AnyType *anyType,
- esxVI_ManagedObjectReference **managedObjectReferenceList,
- const char *expectedType)
-{
- int result = 0;
- xmlNodePtr childNode = NULL;
- esxVI_AnyType *childAnyType = NULL;
- esxVI_ManagedObjectReference *managedObjectReference = NULL;
-
- if (managedObjectReferenceList == NULL ||
- *managedObjectReferenceList != NULL) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
- goto failure;
- }
-
- if (anyType == NULL) {
- return 0;
- }
-
- if (STRNEQ(anyType->other, "ArrayOfManagedObjectReference")) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
- "Expecting type to be 'ArrayOfManagedObjectReference' "
- "but found '%s'", anyType->other);
- goto failure;
- }
-
- for (childNode = anyType->_node->children; childNode != NULL;
- childNode = childNode->next) {
- if (childNode->type != XML_ELEMENT_NODE) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
- "Wrong XML element type %d", childNode->type);
- goto failure;
- }
-
- esxVI_AnyType_Free(&childAnyType);
-
- if (esxVI_AnyType_Deserialize(childNode, &childAnyType) < 0) {
- goto failure;
- }
-
- managedObjectReference = NULL;
-
- if (esxVI_ManagedObjectReference_CastFromAnyType
- (childAnyType, &managedObjectReference, expectedType) < 0) {
- goto failure;
- }
-
- if (esxVI_ManagedObjectReference_AppendToList
- (managedObjectReferenceList, managedObjectReference) < 0) {
- goto failure;
- }
- }
-
+/* esxVI_ManagedObjectReference_CastFromAnyType */
+ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(ManagedObjectReference)
- cleanup:
- esxVI_AnyType_Free(&childAnyType);
-
- return result;
-
- failure:
- esxVI_ManagedObjectReference_Free(managedObjectReferenceList);
-
- result = -1;
-
- goto cleanup;
-}
+/* esxVI_ManagedObjectReference_CastListFromAnyType */
+ESX_VI__TEMPLATE__LIST__CAST_FROM_ANY_TYPE(ManagedObjectReference)
int
esxVI_ManagedObjectReference_Serialize
@@ -1454,8 +1308,7 @@ ESX_VI__TEMPLATE__LIST__SERIALIZE(ManagedObjectReference);
int
esxVI_ManagedObjectReference_Deserialize
- (xmlNodePtr node, esxVI_ManagedObjectReference **managedObjectReference,
- const char *expectedType)
+ (xmlNodePtr node, esxVI_ManagedObjectReference **managedObjectReference)
{
if (managedObjectReference == NULL || *managedObjectReference != NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
@@ -1475,14 +1328,6 @@ esxVI_ManagedObjectReference_Deserialize
goto failure;
}
- if (expectedType != NULL &&
- STRNEQ(expectedType, (*managedObjectReference)->type)) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
- "Expected type '%s' but found '%s'", expectedType,
- (*managedObjectReference)->type);
- goto failure;
- }
-
if (esxVI_String_DeserializeValue(node,
&(*managedObjectReference)->value) < 0) {
goto failure;
@@ -1496,1533 +1341,4 @@ esxVI_ManagedObjectReference_Deserialize
return -1;
}
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: DynamicProperty
- */
-
-/* esxVI_DynamicProperty_Alloc */
-ESX_VI__TEMPLATE__ALLOC(DynamicProperty);
-
-/* esxVI_DynamicProperty_Free */
-ESX_VI__TEMPLATE__FREE(DynamicProperty,
-{
- esxVI_DynamicProperty_Free(&item->_next);
-
- VIR_FREE(item->name);
- esxVI_AnyType_Free(&item->val);
-});
-
-/* esxVI_DynamicProperty_Validate */
-ESX_VI__TEMPLATE__VALIDATE(DynamicProperty,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(name);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(val);
-});
-
-int
-esxVI_DynamicProperty_DeepCopy(esxVI_DynamicProperty **dest,
- esxVI_DynamicProperty *src)
-{
- if (dest == NULL || *dest != NULL) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
- return -1;
- }
-
- if (src == NULL) {
- return 0;
- }
-
- if (esxVI_DynamicProperty_Alloc(dest) < 0 ||
- esxVI_String_DeepCopyValue(&(*dest)->name, src->name) < 0 ||
- esxVI_AnyType_DeepCopy(&(*dest)->val, src->val) < 0) {
- goto failure;
- }
-
- return 0;
-
- failure:
- esxVI_DynamicProperty_Free(dest);
-
- return -1;
-}
-
-/* esxVI_DynamicProperty_DeepCopyList */
-ESX_VI__TEMPLATE__LIST__DEEP_COPY(DynamicProperty);
-
-/* esxVI_DynamicProperty_AppendToList */
-ESX_VI__TEMPLATE__LIST__APPEND(DynamicProperty);
-
-/* esxVI_DynamicProperty_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(DynamicProperty,
-{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, name);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(AnyType, val);
-});
-
-/* esxVI_DynamicProperty_DeserializeList */
-ESX_VI__TEMPLATE__LIST__DESERIALIZE(DynamicProperty);
-
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: HostCpuIdInfo
- */
-
-/* esxVI_HostCpuIdInfo_Alloc */
-ESX_VI__TEMPLATE__ALLOC(HostCpuIdInfo);
-
-/* esxVI_HostCpuIdInfo_Free */
-ESX_VI__TEMPLATE__FREE(HostCpuIdInfo,
-{
- esxVI_HostCpuIdInfo_Free(&item->_next);
-
- esxVI_Int_Free(&item->level);
- VIR_FREE(item->vendor);
- VIR_FREE(item->eax);
- VIR_FREE(item->ebx);
- VIR_FREE(item->ecx);
- VIR_FREE(item->edx);
-});
-
-/* esxVI_HostCpuIdInfo_Validate */
-ESX_VI__TEMPLATE__VALIDATE(HostCpuIdInfo,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(level);
-});
-
-/* esxVI_HostCpuIdInfo_CastFromAnyType */
-ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(HostCpuIdInfo);
-
-/* esxVI_HostCpuIdInfo_CastListFromAnyType */
-ESX_VI__TEMPLATE__LIST__CAST_FROM_ANY_TYPE(HostCpuIdInfo);
-
-/* esxVI_HostCpuIdInfo_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(HostCpuIdInfo,
-{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Int, level);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, vendor);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, eax);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, ebx);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, ecx);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, edx);
-});
-
-/* esxVI_HostCpuIdInfo_DeserializeList */
-ESX_VI__TEMPLATE__LIST__DESERIALIZE(HostCpuIdInfo);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: SelectionSpec
- */
-
-/* esxVI_SelectionSpec_Alloc */
-ESX_VI__TEMPLATE__ALLOC(SelectionSpec);
-
-void
-esxVI_SelectionSpec_Free(esxVI_SelectionSpec **selectionSpec)
-{
- esxVI_SelectionSpec *local = NULL;
-
- if (selectionSpec == NULL || *selectionSpec == NULL) {
- return;
- }
-
- esxVI_SelectionSpec_Free(&(*selectionSpec)->_next);
-
- if ((*selectionSpec)->_super != NULL) {
- /*
- * Explicitly set this pointer to NULL here, otherwise this is will
- * result in a dangling pointer. The actual memory of this object is
- * freed by a call from the esxVI_TraversalSpec_Free function to the
- * esxVI_SelectionSpec_Free function with the base pointer.
- *
- * Use a local copy of the pointer and set the reference to NULL,
- * otherwise Valgrind complains about invalid writes.
- */
- local = *selectionSpec;
- *selectionSpec = NULL;
-
- esxVI_TraversalSpec_Free(&local->_super);
- } else {
- VIR_FREE((*selectionSpec)->name);
-
- VIR_FREE(*selectionSpec);
- }
-}
-
-/* esxVI_SelectionSpec_Validate */
-ESX_VI__TEMPLATE__VALIDATE(SelectionSpec,
-{
- if (item->_super != NULL) {
- return esxVI_TraversalSpec_Validate(item->_super);
- }
-
- /* All properties are optional */
- (void)type_name;
-});
-
-/* esxVI_SelectionSpec_AppendToList */
-ESX_VI__TEMPLATE__LIST__APPEND(SelectionSpec);
-
-int
-esxVI_SelectionSpec_Serialize(esxVI_SelectionSpec *selectionSpec,
- const char *element, virBufferPtr output)
-{
- if (element == NULL || output == NULL) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
- return -1;
- }
-
- if (selectionSpec == NULL) {
- return 0;
- }
-
- if (selectionSpec->_super != NULL) {
- return esxVI_TraversalSpec_Serialize(selectionSpec->_super, element,
- output);
- }
-
- if (esxVI_SelectionSpec_Validate(selectionSpec) < 0) {
- return -1;
- }
-
- ESV_VI__XML_TAG__OPEN(output, element, "SelectionSpec");
-
- if (esxVI_String_SerializeValue(selectionSpec->name, "name", output) < 0) {
- return -1;
- }
-
- ESV_VI__XML_TAG__CLOSE(output, element);
-
- return 0;
-}
-
-/* esxVI_SelectionSpec_SerializeList */
-ESX_VI__TEMPLATE__LIST__SERIALIZE(SelectionSpec);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: TraversalSpec extends SelectionSpec
- */
-
-int
-esxVI_TraversalSpec_Alloc(esxVI_TraversalSpec **traversalSpec)
-{
- if (esxVI_Alloc((void **)traversalSpec, sizeof(esxVI_TraversalSpec)) < 0) {
- return -1;
- }
-
- if (esxVI_SelectionSpec_Alloc(&(*traversalSpec)->_base) < 0) {
- esxVI_TraversalSpec_Free(traversalSpec);
- return -1;
- }
-
- (*traversalSpec)->_base->_super = *traversalSpec;
-
- return 0;
-}
-
-void
-esxVI_TraversalSpec_Free(esxVI_TraversalSpec **traversalSpec)
-{
- esxVI_TraversalSpec *local = NULL;
-
- if (traversalSpec == NULL || *traversalSpec == NULL) {
- return;
- }
-
- /*
- * Need to store the traversalSpec pointer in a local variable here,
- * because it is possible that the traversalSpec pointer and the _super
- * pointer represent the same location in memory, e.g. if
- * esxVI_SelectionSpec_Free calls esxVI_TraversalSpec_Free with the _super
- * pointer as argument. Setting the _super pointer to NULL sets the
- * traversalSpec pointer also to NULL, because we're working on a reference
- * to this pointer here.
- *
- * Also use a local copy of the pointer and set the reference to NULL,
- * otherwise Valgrind complains about invalid writes.
- */
- local = *traversalSpec;
- *traversalSpec = NULL;
-
- /*
- * Setting the _super pointer to NULL here is important, otherwise
- * esxVI_SelectionSpec_Free would call esxVI_TraversalSpec_Free again,
- * resulting in both functions calling each other trying to free the
- * _base/_super object until a stackoverflow occurs.
- */
- local->_base->_super = NULL;
-
- esxVI_SelectionSpec_Free(&local->_base);
- VIR_FREE(local->type);
- VIR_FREE(local->path);
- esxVI_SelectionSpec_Free(&local->selectSet);
-
- VIR_FREE(local);
-}
-
-/* esxVI_TraversalSpec_Validate */
-ESX_VI__TEMPLATE__VALIDATE(TraversalSpec,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(type);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(path);
-});
-
-/* esxVI_TraversalSpec_Serialize */
-ESX_VI__TEMPLATE__SERIALIZE(TraversalSpec,
-{
- if (esxVI_String_SerializeValue(item->_base->name, "name", output) < 0) {
- return -1;
- }
-
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, type);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, path);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Boolean, skip);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(SelectionSpec, selectSet);
-});
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: ObjectSpec
- */
-
-/* esxVI_ObjectSpec_Alloc */
-ESX_VI__TEMPLATE__ALLOC(ObjectSpec);
-
-/* esxVI_ObjectSpec_Free */
-ESX_VI__TEMPLATE__FREE(ObjectSpec,
-{
- esxVI_ObjectSpec_Free(&item->_next);
-
- esxVI_ManagedObjectReference_Free(&item->obj);
- esxVI_SelectionSpec_Free(&item->selectSet);
-});
-
-/* esxVI_ObjectSpec_Validate */
-ESX_VI__TEMPLATE__VALIDATE(ObjectSpec,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(obj);
-});
-
-/* esxVI_ObjectSpec_AppendToList */
-ESX_VI__TEMPLATE__LIST__APPEND(ObjectSpec);
-
-/* esxVI_ObjectSpec_Serialize */
-ESX_VI__TEMPLATE__SERIALIZE(ObjectSpec,
-{
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(ManagedObjectReference, obj);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Boolean, skip);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(SelectionSpec, selectSet);
-});
-
-/* esxVI_ObjectSpec_SerializeList */
-ESX_VI__TEMPLATE__LIST__SERIALIZE(ObjectSpec);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: PropertyChange
- */
-
-/* esxVI_PropertyChange_Alloc */
-ESX_VI__TEMPLATE__ALLOC(PropertyChange);
-
-/* esxVI_PropertyChange_Free */
-ESX_VI__TEMPLATE__FREE(PropertyChange,
-{
- esxVI_PropertyChange_Free(&item->_next);
-
- VIR_FREE(item->name);
- esxVI_AnyType_Free(&item->val);
-});
-
-/* esxVI_PropertyChange_Validate */
-ESX_VI__TEMPLATE__VALIDATE(PropertyChange,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(name);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(op);
-});
-
-/* esxVI_PropertyChange_AppendToList */
-ESX_VI__TEMPLATE__LIST__APPEND(PropertyChange);
-
-/* esxVI_PropertyChange_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(PropertyChange,
-{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, name);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(PropertyChangeOp, op);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(AnyType, val);
-});
-
-/* esxVI_PropertyChange_DeserializeList */
-ESX_VI__TEMPLATE__LIST__DESERIALIZE(PropertyChange);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: PropertySpec
- */
-
-/* esxVI_PropertySpec_Alloc */
-ESX_VI__TEMPLATE__ALLOC(PropertySpec);
-
-/* esxVI_PropertySpec_Free */
-ESX_VI__TEMPLATE__FREE(PropertySpec,
-{
- esxVI_PropertySpec_Free(&item->_next);
-
- VIR_FREE(item->type);
- esxVI_String_Free(&item->pathSet);
-});
-
-/* esxVI_PropertySpec_Validate */
-ESX_VI__TEMPLATE__VALIDATE(PropertySpec,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(type);
-});
-
-/* esxVI_PropertySpec_AppendToList */
-ESX_VI__TEMPLATE__LIST__APPEND(PropertySpec);
-
-/* esxVI_PropertySpec_Serialize */
-ESX_VI__TEMPLATE__SERIALIZE(PropertySpec,
-{
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, type);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Boolean, all);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(String, pathSet);
-});
-
-/* esxVI_PropertySpec_SerializeList */
-ESX_VI__TEMPLATE__LIST__SERIALIZE(PropertySpec);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: PropertyFilterSpec
- */
-
-/* esxVI_PropertyFilterSpec_Alloc */
-ESX_VI__TEMPLATE__ALLOC(PropertyFilterSpec);
-
-/* esxVI_PropertyFilterSpec_Free */
-ESX_VI__TEMPLATE__FREE(PropertyFilterSpec,
-{
- esxVI_PropertyFilterSpec_Free(&item->_next);
-
- esxVI_PropertySpec_Free(&item->propSet);
- esxVI_ObjectSpec_Free(&item->objectSet);
-});
-
-/* esxVI_PropertyFilterSpec_Validate */
-ESX_VI__TEMPLATE__VALIDATE(PropertyFilterSpec,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(propSet);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(objectSet);
-});
-
-/* esxVI_PropertyFilterSpec_AppendToList */
-ESX_VI__TEMPLATE__LIST__APPEND(PropertyFilterSpec);
-
-/* esxVI_PropertyFilterSpec_Serialize */
-ESX_VI__TEMPLATE__SERIALIZE(PropertyFilterSpec,
-{
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(PropertySpec, propSet);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(ObjectSpec, objectSet);
-});
-
-/* esxVI_PropertyFilterSpec_SerializeList */
-ESX_VI__TEMPLATE__LIST__SERIALIZE(PropertyFilterSpec);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: ObjectContent
- */
-
-/* esxVI_ObjectContent_Alloc */
-ESX_VI__TEMPLATE__ALLOC(ObjectContent);
-
-/* esxVI_ObjectContent_Free */
-ESX_VI__TEMPLATE__FREE(ObjectContent,
-{
- esxVI_ObjectContent_Free(&item->_next);
-
- esxVI_ManagedObjectReference_Free(&item->obj);
- esxVI_DynamicProperty_Free(&item->propSet);
- /*esxVI_MissingProperty_Free(&item->missingSet);*//* FIXME */
-});
-
-/* esxVI_ObjectContent_Validate */
-ESX_VI__TEMPLATE__VALIDATE(ObjectContent,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(obj);
-});
-
-/* esxVI_ObjectContent_AppendToList */
-ESX_VI__TEMPLATE__LIST__APPEND(ObjectContent);
-
-int
-esxVI_ObjectContent_DeepCopy(esxVI_ObjectContent **dest,
- esxVI_ObjectContent *src)
-{
- if (dest == NULL || *dest != NULL) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
- return -1;
- }
-
- if (src == NULL) {
- return 0;
- }
-
- if (esxVI_ObjectContent_Alloc(dest) < 0 ||
- esxVI_ManagedObjectReference_DeepCopy(&(*dest)->obj, src->obj) < 0 ||
- esxVI_DynamicProperty_DeepCopyList(&(*dest)->propSet,
- src->propSet) < 0) {
- goto failure;
- }
-
-#if 0 /* FIXME */
- if (esxVI_MissingProperty_DeepCopyList(&(*dest)->missingSet,
- src->missingSet) < 0) {
- goto failure;
- }
-#endif
-
- return 0;
-
- failure:
- esxVI_ObjectContent_Free(dest);
-
- return -1;
-}
-
-/* esxVI_ObjectContent_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(ObjectContent,
-{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- NULL, obj);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_LIST(DynamicProperty, propSet);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_NOOP(missingSet); /* FIXME */
-});
-
-/* esxVI_ObjectContent_DeserializeList */
-ESX_VI__TEMPLATE__LIST__DESERIALIZE(ObjectContent);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: ObjectUpdate
- */
-
-/* esxVI_ObjectUpdate_Alloc */
-ESX_VI__TEMPLATE__ALLOC(ObjectUpdate);
-
-/* esxVI_ObjectUpdate_Free */
-ESX_VI__TEMPLATE__FREE(ObjectUpdate,
-{
- esxVI_ObjectUpdate_Free(&item->_next);
-
- esxVI_ManagedObjectReference_Free(&item->obj);
- esxVI_PropertyChange_Free(&item->changeSet);
- /*esxVI_MissingProperty_Free(&item->missingSet);*//* FIXME */
-});
-
-/* esxVI_ObjectUpdate_Validate */
-ESX_VI__TEMPLATE__VALIDATE(ObjectUpdate,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(kind);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(obj);
-});
-
-/* esxVI_ObjectUpdate_AppendToList */
-ESX_VI__TEMPLATE__LIST__APPEND(ObjectUpdate);
-
-/* esxVI_ObjectUpdate_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(ObjectUpdate,
-{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(ObjectUpdateKind, kind);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- NULL, obj);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_LIST(PropertyChange, changeSet);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_NOOP(missingSet); /* FIXME */
-});
-
-/* esxVI_ObjectUpdate_DeserializeList */
-ESX_VI__TEMPLATE__LIST__DESERIALIZE(ObjectUpdate);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: PropertyFilterUpdate
- */
-
-/* esxVI_PropertyFilterUpdate_Alloc */
-ESX_VI__TEMPLATE__ALLOC(PropertyFilterUpdate);
-
-/* esxVI_PropertyFilterUpdate_Free */
-ESX_VI__TEMPLATE__FREE(PropertyFilterUpdate,
-{
- esxVI_PropertyFilterUpdate_Free(&item->_next);
-
- esxVI_ManagedObjectReference_Free(&item->filter);
- esxVI_ObjectUpdate_Free(&item->objectSet);
- /*esxVI_MissingProperty_Free(&item->missingSet);*//* FIXME */
-});
-
-/* esxVI_PropertyFilterUpdate_Validate */
-ESX_VI__TEMPLATE__VALIDATE(PropertyFilterUpdate,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(filter);
-});
-
-/* esxVI_PropertyFilterUpdate_AppendToList */
-ESX_VI__TEMPLATE__LIST__APPEND(PropertyFilterUpdate);
-
-/* esxVI_PropertyFilterUpdate_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(PropertyFilterUpdate,
-{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- NULL, filter);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_LIST(ObjectUpdate, objectSet);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_NOOP(missingSet); /* FIXME */
-});
-
-/* esxVI_PropertyFilterUpdate_DeserializeList */
-ESX_VI__TEMPLATE__LIST__DESERIALIZE(PropertyFilterUpdate);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: AboutInfo
- */
-
-/* esxVI_AboutInfo_Alloc */
-ESX_VI__TEMPLATE__ALLOC(AboutInfo);
-
-/* esxVI_AboutInfo_Free */
-ESX_VI__TEMPLATE__FREE(AboutInfo,
-{
- VIR_FREE(item->name);
- VIR_FREE(item->fullName);
- VIR_FREE(item->vendor);
- VIR_FREE(item->version);
- VIR_FREE(item->build);
- VIR_FREE(item->localeVersion);
- VIR_FREE(item->localeBuild);
- VIR_FREE(item->osType);
- VIR_FREE(item->productLineId);
- VIR_FREE(item->apiType);
- VIR_FREE(item->apiVersion);
-});
-
-/* esxVI_AboutInfo_Validate */
-ESX_VI__TEMPLATE__VALIDATE(AboutInfo,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(name);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(fullName);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(vendor);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(version);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(build);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(localeVersion);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(localeBuild);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(osType);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(productLineId);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(apiType);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(apiVersion);
-});
-
-/* esxVI_AboutInfo_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(AboutInfo,
-{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, name);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, fullName);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, vendor);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, version);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, build);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, localeVersion);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, localeBuild);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, osType);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, productLineId);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, apiType);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, apiVersion);
-});
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: ServiceContent
- */
-
-/* esxVI_ServiceContent_Alloc */
-ESX_VI__TEMPLATE__ALLOC(ServiceContent);
-
-/* esxVI_ServiceContent_Free */
-ESX_VI__TEMPLATE__FREE(ServiceContent,
-{
- esxVI_ManagedObjectReference_Free(&item->rootFolder);
- esxVI_ManagedObjectReference_Free(&item->propertyCollector);
- esxVI_ManagedObjectReference_Free(&item->viewManager);
- esxVI_AboutInfo_Free(&item->about);
- esxVI_ManagedObjectReference_Free(&item->setting);
- esxVI_ManagedObjectReference_Free(&item->userDirectory);
- esxVI_ManagedObjectReference_Free(&item->sessionManager);
- esxVI_ManagedObjectReference_Free(&item->authorizationManager);
- esxVI_ManagedObjectReference_Free(&item->perfManager);
- esxVI_ManagedObjectReference_Free(&item->scheduledTaskManager);
- esxVI_ManagedObjectReference_Free(&item->alarmManager);
- esxVI_ManagedObjectReference_Free(&item->eventManager);
- esxVI_ManagedObjectReference_Free(&item->taskManager);
- esxVI_ManagedObjectReference_Free(&item->extensionManager);
- esxVI_ManagedObjectReference_Free(&item->customizationSpecManager);
- esxVI_ManagedObjectReference_Free(&item->customFieldsManager);
- esxVI_ManagedObjectReference_Free(&item->accountManager);
- esxVI_ManagedObjectReference_Free(&item->diagnosticManager);
- esxVI_ManagedObjectReference_Free(&item->licenseManager);
- esxVI_ManagedObjectReference_Free(&item->searchIndex);
- esxVI_ManagedObjectReference_Free(&item->fileManager);
- esxVI_ManagedObjectReference_Free(&item->virtualDiskManager);
- esxVI_ManagedObjectReference_Free(&item->virtualizationManager);
-});
-
-/* esxVI_ServiceContent_Validate */
-ESX_VI__TEMPLATE__VALIDATE(ServiceContent,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(rootFolder);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(propertyCollector);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(about);
-});
-
-/* esxVI_ServiceContent_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(ServiceContent,
-{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "Folder", rootFolder);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "PropertyCollector",
- propertyCollector);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "ViewManager",
- viewManager);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(AboutInfo, about);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "OptionManager", setting);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "UserDirectory",
- userDirectory);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "SessionManager",
- sessionManager);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "AuthorizationManager",
- authorizationManager);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "PerformanceManager",
- perfManager);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "ScheduledTaskManager",
- scheduledTaskManager);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "AlarmManager",
- alarmManager);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "EventManager",
- eventManager);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "TaskManager",
- taskManager);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "ExtensionManager",
- extensionManager);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "CustomizationSpecManager",
- customizationSpecManager);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "CustomFieldsManager",
- customFieldsManager);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "HostLocalAccountManager",
- accountManager);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "DiagnosticManager",
- diagnosticManager);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "LicenseManager",
- licenseManager);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "SearchIndex",
- searchIndex);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "FileManager",
- fileManager);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "VirtualDiskManager",
- virtualDiskManager);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "VirtualizationManager",
- virtualizationManager);
-});
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: UpdateSet
- */
-
-/* esxVI_UpdateSet_Alloc */
-ESX_VI__TEMPLATE__ALLOC(UpdateSet);
-
-/* esxVI_UpdateSet_Free */
-ESX_VI__TEMPLATE__FREE(UpdateSet,
-{
- VIR_FREE(item->version);
- esxVI_PropertyFilterUpdate_Free(&item->filterSet);
-});
-
-/* esxVI_UpdateSet_Validate */
-ESX_VI__TEMPLATE__VALIDATE(UpdateSet,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(version);
-});
-
-/* esxVI_UpdateSet_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(UpdateSet,
-{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, version);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_LIST(PropertyFilterUpdate,
- filterSet);
-});
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: SharesInfo
- */
-
-/* esxVI_SharesInfo_Alloc */
-ESX_VI__TEMPLATE__ALLOC(SharesInfo);
-
-/* esxVI_SharesInfo_Free */
-ESX_VI__TEMPLATE__FREE(SharesInfo,
-{
- esxVI_Int_Free(&item->shares);
-});
-
-/* esxVI_SharesInfo_Validate */
-ESX_VI__TEMPLATE__VALIDATE(SharesInfo,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(shares);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(level);
-});
-
-/* esxVI_SharesInfo_CastFromAnyType */
-ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(SharesInfo);
-
-/* esxVI_SharesInfo_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(SharesInfo,
-{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Int, shares);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(SharesLevel, level);
-});
-
-/* esxVI_SharesInfo_Serialize */
-ESX_VI__TEMPLATE__SERIALIZE(SharesInfo,
-{
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Int, shares);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(SharesLevel, level);
-});
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: ResourceAllocationInfo
- */
-
-/* esxVI_ResourceAllocationInfo_Alloc */
-ESX_VI__TEMPLATE__ALLOC(ResourceAllocationInfo);
-
-/* esxVI_ResourceAllocationInfo_Free */
-ESX_VI__TEMPLATE__FREE(ResourceAllocationInfo,
-{
- esxVI_Long_Free(&item->reservation);
- esxVI_Long_Free(&item->limit);
- esxVI_SharesInfo_Free(&item->shares);
- esxVI_Long_Free(&item->overheadLimit);
-});
-
-/* esxVI_ResourceAllocationInfo_Validate */
-ESX_VI__TEMPLATE__VALIDATE_NOOP(ResourceAllocationInfo);
-
-/* esxVI_ResourceAllocationInfo_Serialize */
-ESX_VI__TEMPLATE__SERIALIZE(ResourceAllocationInfo,
-{
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Long, reservation);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Boolean, expandableReservation);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Long, limit);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(SharesInfo, shares);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Long, overheadLimit);
-});
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: ResourcePoolResourceUsage
- */
-
-/* esxVI_ResourcePoolResourceUsage_Alloc */
-ESX_VI__TEMPLATE__ALLOC(ResourcePoolResourceUsage);
-
-/* esxVI_ResourcePoolResourceUsage_Free */
-ESX_VI__TEMPLATE__FREE(ResourcePoolResourceUsage,
-{
- esxVI_Long_Free(&item->reservationUsed);
- esxVI_Long_Free(&item->reservationUsedForVm);
- esxVI_Long_Free(&item->unreservedForPool);
- esxVI_Long_Free(&item->unreservedForVm);
- esxVI_Long_Free(&item->overallUsage);
- esxVI_Long_Free(&item->maxUsage);
-});
-
-/* esxVI_ResourcePoolResourceUsage_Validate */
-ESX_VI__TEMPLATE__VALIDATE(ResourcePoolResourceUsage,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(reservationUsed);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(reservationUsedForVm);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(unreservedForPool);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(unreservedForVm);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(overallUsage);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(maxUsage);
-});
-
-/* esxVI_ResourcePoolResourceUsage_CastFromAnyType */
-ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(ResourcePoolResourceUsage);
-
-/* esxVI_ResourcePoolResourceUsage_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(ResourcePoolResourceUsage,
-{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Long, reservationUsed);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Long, reservationUsedForVm);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Long, unreservedForPool);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Long, unreservedForVm);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Long, overallUsage);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Long, maxUsage);
-});
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: VirtualMachineConfigSpec
- */
-
-/* esxVI_VirtualMachineConfigSpec_Alloc */
-ESX_VI__TEMPLATE__ALLOC(VirtualMachineConfigSpec);
-
-/* esxVI_VirtualMachineConfigSpec_Free */
-ESX_VI__TEMPLATE__FREE(VirtualMachineConfigSpec,
-{
- VIR_FREE(item->changeVersion);
- VIR_FREE(item->name);
- VIR_FREE(item->version);
- VIR_FREE(item->uuid);
- esxVI_Long_Free(&item->npivNodeWorldWideName);
- esxVI_Long_Free(&item->npivPortWorldWideName);
- VIR_FREE(item->npivWorldWideNameType);
- VIR_FREE(item->npivWorldWideNameOp);
- VIR_FREE(item->locationId);
- VIR_FREE(item->guestId);
- VIR_FREE(item->alternateGuestName);
- VIR_FREE(item->annotation);
- /* FIXME: implement missing */
- esxVI_Int_Free(&item->numCPUs);
- esxVI_Long_Free(&item->memoryMB);
- /* FIXME: implement missing */
- esxVI_ResourceAllocationInfo_Free(&item->cpuAllocation);
- esxVI_ResourceAllocationInfo_Free(&item->memoryAllocation);
- /* FIXME: implement missing */
- VIR_FREE(item->swapPlacement);
- /* FIXME: implement missing */
-});
-
-/* esxVI_VirtualMachineConfigSpec_Validate */
-ESX_VI__TEMPLATE__VALIDATE_NOOP(VirtualMachineConfigSpec);
-
-/* esxVI_VirtualMachineConfigSpec_Serialize */
-ESX_VI__TEMPLATE__SERIALIZE(VirtualMachineConfigSpec,
-{
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, changeVersion);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, name);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, version);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, uuid);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(Long, npivNodeWorldWideName);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(Long, npivPortWorldWideName);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, npivWorldWideNameType);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, npivWorldWideNameOp);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, locationId);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, guestId);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, alternateGuestName);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, annotation);
- /* FIXME: implement missing */
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Int, numCPUs);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Long, memoryMB);
- /* FIXME: implement missing */
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(ResourceAllocationInfo,
- cpuAllocation);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(ResourceAllocationInfo,
- memoryAllocation);
- /* FIXME: implement missing */
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, swapPlacement);
- /* FIXME: implement missing */
-});
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: Event
- */
-
-/* esxVI_Event_Alloc */
-ESX_VI__TEMPLATE__ALLOC(Event);
-
-/* esxVI_Event_Free */
-ESX_VI__TEMPLATE__FREE(Event,
-{
- esxVI_Event_Free(&item->_next);
-
- /* FIXME: implement the rest */
- esxVI_Int_Free(&item->key);
- esxVI_Int_Free(&item->chainId);
- esxVI_DateTime_Free(&item->createdTime);
- VIR_FREE(item->userName);
- VIR_FREE(item->fullFormattedMessage);
-});
-
-/* esxVI_Event_Validate */
-ESX_VI__TEMPLATE__VALIDATE(Event,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(key);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(chainId);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(createdTime);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(userName);
-});
-
-/* esxVI_Event_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(Event,
-{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Int, key);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Int, chainId);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(DateTime, createdTime);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, userName);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_NOOP(datacenter); /* FIXME */
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_NOOP(computeResource); /* FIXME */
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_NOOP(host); /* FIXME */
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_NOOP(vm); /* FIXME */
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, fullFormattedMessage);
-});
-
-/* esxVI_Event_DeserializeList */
-ESX_VI__TEMPLATE__LIST__DESERIALIZE(Event);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: UserSession
- */
-
-/* esxVI_UserSession_Alloc */
-ESX_VI__TEMPLATE__ALLOC(UserSession);
-
-/* esxVI_UserSession_Free */
-ESX_VI__TEMPLATE__FREE(UserSession,
-{
- VIR_FREE(item->key);
- VIR_FREE(item->userName);
- VIR_FREE(item->fullName);
- esxVI_DateTime_Free(&item->loginTime);
- esxVI_DateTime_Free(&item->lastActiveTime);
- VIR_FREE(item->locale);
- VIR_FREE(item->messageLocale);
-});
-
-/* esxVI_UserSession_Validate */
-ESX_VI__TEMPLATE__VALIDATE(UserSession,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(key);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(userName);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(fullName);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(loginTime);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(lastActiveTime);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(locale);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(messageLocale);
-});
-
-/* esxVI_UserSession_CastFromAnyType */
-ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(UserSession);
-
-/* esxVI_UserSession_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(UserSession,
-{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, key);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, userName);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, fullName);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(DateTime, loginTime);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(DateTime, lastActiveTime);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, locale);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, messageLocale);
-});
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: VirtualMachineQuestionInfo
- */
-
-/* esxVI_VirtualMachineQuestionInfo_Alloc */
-ESX_VI__TEMPLATE__ALLOC(VirtualMachineQuestionInfo);
-
-/* esxVI_VirtualMachineQuestionInfo_Free */
-ESX_VI__TEMPLATE__FREE(VirtualMachineQuestionInfo,
-{
- VIR_FREE(item->id);
- VIR_FREE(item->text);
- esxVI_ChoiceOption_Free(&item->choice);
- /*esxVI_VirtualMachineMessage_Free(&item->message);*//* FIXME */
-});
-
-/* esxVI_VirtualMachineQuestionInfo_Validate */
-ESX_VI__TEMPLATE__VALIDATE(VirtualMachineQuestionInfo,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(id);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(text);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(choice);
-});
-
-/* esxVI_VirtualMachineQuestionInfo_CastFromAnyType */
-ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(VirtualMachineQuestionInfo);
-
-/* esxVI_VirtualMachineQuestionInfo_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(VirtualMachineQuestionInfo,
-{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, id);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, text);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(ChoiceOption, choice);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_NOOP(message); /* FIXME */
-});
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: ElementDescription extends Description
- *
- * In contrast to SelectionSpec and TraversalSpec just merge
- * Description into ElementDescription for simplicity, because
- * only ElementDescription is used.
- */
-
-/* esxVI_ElementDescription_Alloc */
-ESX_VI__TEMPLATE__ALLOC(ElementDescription);
-
-/* esxVI_ElementDescription_Free */
-ESX_VI__TEMPLATE__FREE(ElementDescription,
-{
- esxVI_ElementDescription_Free(&item->_next);
-
- VIR_FREE(item->label);
- VIR_FREE(item->summary);
- VIR_FREE(item->key);
-});
-
-/* esxVI_ElementDescription_Validate */
-ESX_VI__TEMPLATE__VALIDATE(ElementDescription,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(label);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(summary);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(key);
-});
-
-/* esxVI_ElementDescription_AppendToList */
-ESX_VI__TEMPLATE__LIST__APPEND(ElementDescription);
-
-/* esxVI_ElementDescription_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(ElementDescription,
-{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, label);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, summary);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, key);
-});
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: ChoiceOption extends OptionType
- *
- * In contrast to SelectionSpec and TraversalSpec just merge
- * OptionType into ChoiceOption for simplicity, because
- * only ChoiceOption is used.
- */
-
-/* esxVI_ChoiceOption_Alloc */
-ESX_VI__TEMPLATE__ALLOC(ChoiceOption);
-
-/* esxVI_ChoiceOption_Free */
-ESX_VI__TEMPLATE__FREE(ChoiceOption,
-{
- esxVI_ElementDescription_Free(&item->choiceInfo);
- esxVI_Int_Free(&item->defaultIndex);
-});
-
-/* esxVI_ChoiceOption_Validate */
-ESX_VI__TEMPLATE__VALIDATE(ChoiceOption,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(choiceInfo);
-});
-
-/* esxVI_ChoiceOption_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(ChoiceOption,
-{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Boolean, valueIsReadonly);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_LIST(ElementDescription, choiceInfo);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Int, defaultIndex);
-});
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: PerfMetricId
- */
-
-/* esxVI_PerfMetricId_Alloc */
-ESX_VI__TEMPLATE__ALLOC(PerfMetricId);
-
-/* esxVI_PerfMetricId_Free */
-ESX_VI__TEMPLATE__FREE(PerfMetricId,
-{
- esxVI_PerfMetricId_Free(&item->_next);
-
- esxVI_Int_Free(&item->counterId);
- VIR_FREE(item->instance);
-});
-
-/* esxVI_PerfMetricId_Validate */
-ESX_VI__TEMPLATE__VALIDATE(PerfMetricId,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(counterId);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(instance);
-});
-
-/* esxVI_PerfMetricId_Serialize */
-ESX_VI__TEMPLATE__SERIALIZE(PerfMetricId,
-{
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Int, counterId);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, instance);
-});
-
-/* esxVI_PerfMetricId_SerializeList */
-ESX_VI__TEMPLATE__LIST__SERIALIZE(PerfMetricId);
-
-/* esxVI_PerfMetricId_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(PerfMetricId,
-{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Int, counterId);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, instance);
-});
-
-/* esxVI_PerfMetricId_DeserializeList */
-ESX_VI__TEMPLATE__LIST__DESERIALIZE(PerfMetricId);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: PerfCounterInfo
- */
-
-/* esxVI_PerfCounterInfo_Alloc */
-ESX_VI__TEMPLATE__ALLOC(PerfCounterInfo);
-
-/* esxVI_PerfCounterInfo_Free */
-ESX_VI__TEMPLATE__FREE(PerfCounterInfo,
-{
- esxVI_PerfCounterInfo_Free(&item->_next);
-
- esxVI_Int_Free(&item->key);
- esxVI_ElementDescription_Free(&item->nameInfo);
- esxVI_ElementDescription_Free(&item->groupInfo);
- esxVI_ElementDescription_Free(&item->unitInfo);
- esxVI_Int_Free(&item->level);
- esxVI_Int_Free(&item->associatedCounterId);
-});
-
-/* esxVI_PerfCounterInfo_Validate */
-ESX_VI__TEMPLATE__VALIDATE(PerfCounterInfo,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(key);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(nameInfo);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(groupInfo);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(unitInfo);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(rollupType);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(statsType);
-});
-
-/* esxVI_PerfCounterInfo_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(PerfCounterInfo,
-{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Int, key);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(ElementDescription, nameInfo);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(ElementDescription, groupInfo);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(ElementDescription, unitInfo);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(PerfSummaryType, rollupType);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(PerfStatsType, statsType);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Int, level);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_LIST(Int, associatedCounterId);
-});
-
-/* esxVI_PerfCounterInfo_DeserializeList */
-ESX_VI__TEMPLATE__LIST__DESERIALIZE(PerfCounterInfo);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: PerfQuerySpec
- */
-
-/* esxVI_PerfQuerySpec_Alloc */
-ESX_VI__TEMPLATE__ALLOC(PerfQuerySpec);
-
-/* esxVI_PerfQuerySpec_Free */
-ESX_VI__TEMPLATE__FREE(PerfQuerySpec,
-{
- esxVI_PerfQuerySpec_Free(&item->_next);
-
- esxVI_ManagedObjectReference_Free(&item->entity);
- esxVI_DateTime_Free(&item->startTime);
- esxVI_DateTime_Free(&item->endTime);
- esxVI_Int_Free(&item->maxSample);
- esxVI_PerfMetricId_Free(&item->metricId);
- esxVI_Int_Free(&item->intervalId);
- VIR_FREE(item->format);
-});
-
-/* esxVI_PerfQuerySpec_Validate */
-ESX_VI__TEMPLATE__VALIDATE(PerfQuerySpec,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(entity);
-});
-
-/* esxVI_PerfQuerySpec_Serialize */
-ESX_VI__TEMPLATE__SERIALIZE(PerfQuerySpec,
-{
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(ManagedObjectReference, entity);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(DateTime, startTime);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(DateTime, endTime);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Int, maxSample);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(PerfMetricId, metricId);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Int, intervalId);
- ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, format);
-});
-
-/* esxVI_PerfQuerySpec_SerializeList */
-ESX_VI__TEMPLATE__LIST__SERIALIZE(PerfQuerySpec);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: PerfSampleInfo
- */
-
-/* esxVI_PerfSampleInfo_Alloc */
-ESX_VI__TEMPLATE__ALLOC(PerfSampleInfo);
-
-/* esxVI_PerfSampleInfo_Free */
-ESX_VI__TEMPLATE__FREE(PerfSampleInfo,
-{
- esxVI_PerfSampleInfo_Free(&item->_next);
-
- esxVI_DateTime_Free(&item->timestamp);
- esxVI_Int_Free(&item->interval);
-});
-
-/* esxVI_PerfSampleInfo_Validate */
-ESX_VI__TEMPLATE__VALIDATE(PerfSampleInfo,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(timestamp);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(interval);
-});
-
-/* esxVI_PerfSampleInfo_AppendToList */
-ESX_VI__TEMPLATE__LIST__APPEND(PerfSampleInfo);
-
-/* esxVI_PerfSampleInfo_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(PerfSampleInfo,
-{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(DateTime, timestamp);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Int, interval);
-});
-
-/* esxVI_PerfSampleInfo_DeserializeList */
-ESX_VI__TEMPLATE__LIST__DESERIALIZE(PerfSampleInfo);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: PerfMetricIntSeries extends PerfMetricSeries
- *
- * In contrast to SelectionSpec and TraversalSpec just merge
- * PerfMetricSeries into PerfMetricIntSeries for simplicity, because
- * only PerfMetricIntSeries is used and the other type inheriting
- * PerfMetricSeries (PerfMetricSeriesCSV) is not used.
- */
-
-/* esxVI_PerfMetricIntSeries_Alloc */
-ESX_VI__TEMPLATE__ALLOC(PerfMetricIntSeries);
-
-/* esxVI_PerfMetricIntSeries_Free */
-ESX_VI__TEMPLATE__FREE(PerfMetricIntSeries,
-{
- esxVI_PerfMetricIntSeries_Free(&item->_next);
-
- esxVI_PerfMetricId_Free(&item->id);
- esxVI_Long_Free(&item->value);
-});
-
-/* esxVI_PerfMetricIntSeries_Validate */
-ESX_VI__TEMPLATE__VALIDATE(PerfMetricIntSeries,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(id);
-});
-
-/* esxVI_PerfMetricIntSeries_AppendToList */
-ESX_VI__TEMPLATE__LIST__APPEND(PerfMetricIntSeries);
-
-/* esxVI_PerfMetricIntSeries_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(PerfMetricIntSeries,
-{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(PerfMetricId, id);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_LIST(Long, value);
-});
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: PerfEntityMetric extends PerfEntityMetricBase
- *
- * In contrast to SelectionSpec and TraversalSpec just merge
- * PerfEntityMetricBase into PerfEntityMetric for simplicity, because
- * only PerfEntityMetric is used and the other type inheriting
- * PerfEntityMetric (PerfEntityMetricCSV) is not used.
- *
- * Also use PerfMetricIntSeries instead of the correct base type
- * PerfMetricSeries for the value property, because only
- * PerfMetricIntSeries is used.
- */
-
-/* esxVI_PerfEntityMetric_Alloc */
-ESX_VI__TEMPLATE__ALLOC(PerfEntityMetric);
-
-/* esxVI_PerfEntityMetric_Free */
-ESX_VI__TEMPLATE__FREE(PerfEntityMetric,
-{
- esxVI_PerfEntityMetric_Free(&item->_next);
-
- esxVI_ManagedObjectReference_Free(&item->entity);
- esxVI_PerfSampleInfo_Free(&item->sampleInfo);
- esxVI_PerfMetricIntSeries_Free(&item->value);
-});
-
-/* esxVI_PerfEntityMetric_Validate */
-ESX_VI__TEMPLATE__VALIDATE(PerfEntityMetric,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(entity);
-});
-
-/* esxVI_PerfEntityMetric_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(PerfEntityMetric,
-{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- NULL, entity);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_LIST(PerfSampleInfo, sampleInfo);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_LIST(PerfMetricIntSeries, value);
-});
-
-/* esxVI_PerfEntityMetric_DeserializeList */
-ESX_VI__TEMPLATE__LIST__DESERIALIZE(PerfEntityMetric);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: TaskInfo
- */
-
-/* esxVI_TaskInfo_Alloc */
-ESX_VI__TEMPLATE__ALLOC(TaskInfo);
-
-/* esxVI_TaskInfo_Free */
-ESX_VI__TEMPLATE__FREE(TaskInfo,
-{
- esxVI_TaskInfo_Free(&item->_next);
-
- VIR_FREE(item->key);
- esxVI_ManagedObjectReference_Free(&item->task);
- VIR_FREE(item->name);
- VIR_FREE(item->descriptionId);
- esxVI_ManagedObjectReference_Free(&item->entity);
- VIR_FREE(item->entityName);
- /*esxVI_ManagedObjectReference_Free(&item->locked);*//* FIXME */
- /*esxVI_MethodFault_Free(&item->error);*//* FIXME */
- esxVI_AnyType_Free(&item->result);
- esxVI_Int_Free(&item->progress);
- /*esxVI_TaskReason_Free(&item->reason);*//* FIXME */
- esxVI_DateTime_Free(&item->queueTime);
- esxVI_DateTime_Free(&item->startTime);
- esxVI_DateTime_Free(&item->completeTime);
- esxVI_Int_Free(&item->eventChainId);
-});
-
-/* esxVI_TaskInfo_Validate */
-ESX_VI__TEMPLATE__VALIDATE(TaskInfo,
-{
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(key);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(task);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(descriptionId);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(state);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(cancelled);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(cancelable);
- /*ESX_VI__TEMPLATE__PROPERTY__REQUIRE(reason);*//* FIXME */
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(queueTime);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(eventChainId);
-});
-
-/* esxVI_TaskInfo_CastFromAnyType */
-ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(TaskInfo);
-
-/* esxVI_TaskInfo_AppendToList */
-ESX_VI__TEMPLATE__LIST__APPEND(TaskInfo);
-
-/* esxVI_TaskInfo_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(TaskInfo,
-{
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, key);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- "Task", task);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, name);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, descriptionId);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
- NULL, entity);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, entityName);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_NOOP(locked); /* FIXME */
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(TaskInfoState, state);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Boolean, cancelled);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Boolean, cancelable);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_NOOP(error); /* FIXME */
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(AnyType, result);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Int, progress);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_NOOP(reason); /* FIXME */
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(DateTime, queueTime);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(DateTime, startTime);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(DateTime, completeTime);
- ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Int, eventChainId);
-});
+#include "esx_vi_types.generated.c"
diff --git a/src/esx/esx_vi_types.h b/src/esx/esx_vi_types.h
index e5451e9..a61cdc1 100644
--- a/src/esx/esx_vi_types.h
+++ b/src/esx/esx_vi_types.h
@@ -25,13 +25,8 @@
# include "buf.h"
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * XSI
- */
-
typedef enum _esxVI_Type esxVI_Type;
+typedef struct _esxVI_Object esxVI_Object;
@@ -49,75 +44,50 @@ typedef struct _esxVI_DateTime esxVI_DateTime;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Enums
- */
-
-typedef enum _esxVI_ManagedEntityStatus esxVI_ManagedEntityStatus;
-typedef enum _esxVI_ObjectUpdateKind esxVI_ObjectUpdateKind;
-typedef enum _esxVI_PerfSummaryType esxVI_PerfSummaryType;
-typedef enum _esxVI_PerfStatsType esxVI_PerfStatsType;
-typedef enum _esxVI_PropertyChangeOp esxVI_PropertyChangeOp;
-typedef enum _esxVI_SharesLevel esxVI_SharesLevel;
-typedef enum _esxVI_TaskInfoState esxVI_TaskInfoState;
-typedef enum _esxVI_VirtualMachineMovePriority esxVI_VirtualMachineMovePriority;
-typedef enum _esxVI_VirtualMachinePowerState esxVI_VirtualMachinePowerState;
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* VI Types
*/
typedef struct _esxVI_Fault esxVI_Fault;
typedef struct _esxVI_ManagedObjectReference esxVI_ManagedObjectReference;
-typedef struct _esxVI_DynamicProperty esxVI_DynamicProperty;
-typedef struct _esxVI_HostCpuIdInfo esxVI_HostCpuIdInfo;
-typedef struct _esxVI_SelectionSpec esxVI_SelectionSpec;
-typedef struct _esxVI_TraversalSpec esxVI_TraversalSpec;
-typedef struct _esxVI_ObjectSpec esxVI_ObjectSpec;
-typedef struct _esxVI_PropertyChange esxVI_PropertyChange;
-typedef struct _esxVI_PropertySpec esxVI_PropertySpec;
-typedef struct _esxVI_PropertyFilterSpec esxVI_PropertyFilterSpec;
-typedef struct _esxVI_ObjectContent esxVI_ObjectContent;
-typedef struct _esxVI_ObjectUpdate esxVI_ObjectUpdate;
-typedef struct _esxVI_PropertyFilterUpdate esxVI_PropertyFilterUpdate;
-typedef struct _esxVI_AboutInfo esxVI_AboutInfo;
-typedef struct _esxVI_ServiceContent esxVI_ServiceContent;
-typedef struct _esxVI_UpdateSet esxVI_UpdateSet;
-typedef struct _esxVI_SharesInfo esxVI_SharesInfo;
-typedef struct _esxVI_ResourceAllocationInfo esxVI_ResourceAllocationInfo;
-typedef struct _esxVI_ResourcePoolResourceUsage esxVI_ResourcePoolResourceUsage;
-typedef struct _esxVI_VirtualMachineConfigSpec esxVI_VirtualMachineConfigSpec;
-typedef struct _esxVI_Event esxVI_Event;
-typedef struct _esxVI_UserSession esxVI_UserSession;
-typedef struct _esxVI_VirtualMachineQuestionInfo esxVI_VirtualMachineQuestionInfo;
-typedef struct _esxVI_ElementDescription esxVI_ElementDescription;
-typedef struct _esxVI_ChoiceOption esxVI_ChoiceOption;
-typedef struct _esxVI_PerfMetricId esxVI_PerfMetricId;
-typedef struct _esxVI_PerfCounterInfo esxVI_PerfCounterInfo;
-typedef struct _esxVI_PerfQuerySpec esxVI_PerfQuerySpec;
-typedef struct _esxVI_PerfSampleInfo esxVI_PerfSampleInfo;
-typedef struct _esxVI_PerfMetricIntSeries esxVI_PerfMetricIntSeries;
-typedef struct _esxVI_PerfEntityMetric esxVI_PerfEntityMetric;
-typedef struct _esxVI_TaskInfo esxVI_TaskInfo;
+
+#include "esx_vi_types.generated.typedef"
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * XSI: Type
+ * Type
*/
enum _esxVI_Type {
esxVI_Type_Undefined = 0,
esxVI_Type_Boolean,
+ esxVI_Type_AnyType,
esxVI_Type_String,
esxVI_Type_Short,
esxVI_Type_Int,
esxVI_Type_Long,
+ esxVI_Type_DateTime,
+ esxVI_Type_Fault,
+ esxVI_Type_ManagedObjectReference,
+
+#include "esx_vi_types.generated.typeenum"
+
esxVI_Type_Other,
};
-const char *esxVI_Type_Name(esxVI_Type type);
+const char *esxVI_Type_ToString(esxVI_Type type);
+esxVI_Type esxVI_Type_FromString(const char *type);
+
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Object extends List
+ */
+
+struct _esxVI_Object {
+ esxVI_Object *_next; /* optional */
+ esxVI_Type _type; /* required */
+};
@@ -142,8 +112,10 @@ int esxVI_Boolean_Deserialize(xmlNodePtr node, esxVI_Boolean *boolean_);
*/
struct _esxVI_AnyType {
- xmlNodePtr _node; /* required */
+ esxVI_AnyType *_unused; /* optional */
+ esxVI_Type _type; /* = esxVI_Type_AnyType */ /* required */
+ xmlNodePtr node; /* required */
esxVI_Type type; /* required */
char *other; /* required */
char *value; /* required */
@@ -170,12 +142,14 @@ int esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType);
struct _esxVI_String {
esxVI_String *_next; /* optional */
+ esxVI_Type _type; /* required */
char *value; /* required */
};
int esxVI_String_Alloc(esxVI_String **string);
void esxVI_String_Free(esxVI_String **stringList);
+int esxVI_String_Validate(esxVI_String *string);
int esxVI_String_AppendToList(esxVI_String **stringList, esxVI_String *string);
int esxVI_String_AppendValueToList(esxVI_String **stringList,
const char *value);
@@ -202,6 +176,7 @@ int esxVI_String_DeserializeValue(xmlNodePtr node, char **value);
struct _esxVI_Int {
esxVI_Int *_next; /* optional */
+ esxVI_Type _type; /* required */
int32_t value; /* required */
};
@@ -225,6 +200,7 @@ int esxVI_Int_Deserialize(xmlNodePtr node, esxVI_Int **number);
struct _esxVI_Long {
esxVI_Long *_next; /* optional */
+ esxVI_Type _type; /* required */
int64_t value; /* required */
};
@@ -246,6 +222,9 @@ int esxVI_Long_Deserialize(xmlNodePtr node, esxVI_Long **number);
*/
struct _esxVI_DateTime {
+ esxVI_DateTime *_unused; /* optional */
+ esxVI_Type _type; /* required */
+
char *value; /* required */
};
@@ -259,170 +238,13 @@ int esxVI_DateTime_Deserialize(xmlNodePtr node, esxVI_DateTime **dateTime);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Enum: ManagedEntityStatus
- */
-
-enum _esxVI_ManagedEntityStatus {
- esxVI_ManagedEntityStatus_Undefined = 0,
- esxVI_ManagedEntityStatus_Gray,
- esxVI_ManagedEntityStatus_Green,
- esxVI_ManagedEntityStatus_Yellow,
- esxVI_ManagedEntityStatus_Red,
-};
-
-int esxVI_ManagedEntityStatus_CastFromAnyType
- (esxVI_AnyType *anyType, esxVI_ManagedEntityStatus *managedEntityStatus);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Enum: ObjectUpdateKind
- */
-
-enum _esxVI_ObjectUpdateKind {
- esxVI_ObjectUpdateKind_Undefined = 0,
- esxVI_ObjectUpdateKind_Enter,
- esxVI_ObjectUpdateKind_Leave,
- esxVI_ObjectUpdateKind_Modify,
-};
-
-int esxVI_ObjectUpdateKind_Deserialize
- (xmlNodePtr node, esxVI_ObjectUpdateKind *objectUpdateKind);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Enum: PerfSummaryType
- */
-
-enum _esxVI_PerfSummaryType {
- esxVI_PerfSummaryType_Undefined = 0,
- esxVI_PerfSummaryType_Average,
- esxVI_PerfSummaryType_Latest,
- esxVI_PerfSummaryType_Maximum,
- esxVI_PerfSummaryType_Minimum,
- esxVI_PerfSummaryType_None,
- esxVI_PerfSummaryType_Summation,
-};
-
-int esxVI_PerfSummaryType_Deserialize(xmlNodePtr node,
- esxVI_PerfSummaryType *perfSummaryType);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Enum: PerfStatsType
- */
-
-enum _esxVI_PerfStatsType {
- esxVI_PerfStatsType_Undefined = 0,
- esxVI_PerfStatsType_Absolute,
- esxVI_PerfStatsType_Delta,
- esxVI_PerfStatsType_Rate,
-};
-
-int esxVI_PerfStatsType_Deserialize(xmlNodePtr node,
- esxVI_PerfStatsType *perfStatsType);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Enum: PropertyChangeOp
- */
-
-enum _esxVI_PropertyChangeOp {
- esxVI_PropertyChangeOp_Undefined = 0,
- esxVI_PropertyChangeOp_Add,
- esxVI_PropertyChangeOp_Remove,
- esxVI_PropertyChangeOp_Assign,
- esxVI_PropertyChangeOp_IndirectRemove,
-};
-
-int esxVI_PropertyChangeOp_Deserialize
- (xmlNodePtr node, esxVI_PropertyChangeOp *propertyChangeOp);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Enum: SharesLevel
- */
-
-enum _esxVI_SharesLevel {
- esxVI_SharesLevel_Undefined = 0,
- esxVI_SharesLevel_Custom,
- esxVI_SharesLevel_High,
- esxVI_SharesLevel_Low,
- esxVI_SharesLevel_Normal,
-};
-
-int esxVI_SharesLevel_Serialize(esxVI_SharesLevel sharesLevel,
- const char *element, virBufferPtr output);
-int esxVI_SharesLevel_Deserialize(xmlNodePtr node,
- esxVI_SharesLevel *sharesLevel);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Enum: TaskInfoState
- */
-
-enum _esxVI_TaskInfoState {
- esxVI_TaskInfoState_Undefined = 0,
- esxVI_TaskInfoState_Error,
- esxVI_TaskInfoState_Queued,
- esxVI_TaskInfoState_Running,
- esxVI_TaskInfoState_Success,
-};
-
-int esxVI_TaskInfoState_CastFromAnyType(esxVI_AnyType *anyType,
- esxVI_TaskInfoState *taskInfoState);
-int esxVI_TaskInfoState_Deserialize(xmlNodePtr node,
- esxVI_TaskInfoState *taskInfoState);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Enum: VirtualMachineMovePriority
- */
-
-enum _esxVI_VirtualMachineMovePriority {
- esxVI_VirtualMachineMovePriority_Undefined = 0,
- esxVI_VirtualMachineMovePriority_LowPriority,
- esxVI_VirtualMachineMovePriority_HighPriority,
- esxVI_VirtualMachineMovePriority_DefaultPriority,
-};
-
-int esxVI_VirtualMachineMovePriority_Serialize
- (esxVI_VirtualMachineMovePriority virtualMachineMovePriority,
- const char *element, virBufferPtr output);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Enum: VirtualMachinePowerState
- */
-
-enum _esxVI_VirtualMachinePowerState {
- esxVI_VirtualMachinePowerState_Undefined = 0,
- esxVI_VirtualMachinePowerState_PoweredOff,
- esxVI_VirtualMachinePowerState_PoweredOn,
- esxVI_VirtualMachinePowerState_Suspended,
-};
-
-int esxVI_VirtualMachinePowerState_CastFromAnyType
- (esxVI_AnyType *anyType,
- esxVI_VirtualMachinePowerState *virtualMachinePowerState);
-int esxVI_VirtualMachinePowerState_Serialize
- (esxVI_VirtualMachinePowerState virtualMachinePowerState,
- const char *element, virBufferPtr output);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* VI Type: Fault
*/
struct _esxVI_Fault {
+ esxVI_Fault *_unused; /* optional */
+ esxVI_Type _type; /* required */
+
char *faultcode; /* required */
char *faultstring; /* required */
};
@@ -440,6 +262,7 @@ int esxVI_Fault_Deserialize(xmlNodePtr node, esxVI_Fault **fault);
struct _esxVI_ManagedObjectReference {
esxVI_ManagedObjectReference *_next; /* optional */
+ esxVI_Type _type; /* required */
char *type; /* required */
char *value; /* required */
@@ -454,14 +277,12 @@ int esxVI_ManagedObjectReference_DeepCopy(esxVI_ManagedObjectReference **dest,
int esxVI_ManagedObjectReference_AppendToList
(esxVI_ManagedObjectReference **managedObjectReferenceList,
esxVI_ManagedObjectReference *managedObjectReference);
-int esxVI_ManagedObjectReference_CastFromAnyType(esxVI_AnyType *anyType,
- esxVI_ManagedObjectReference
- **managedObjectReference,
- const char *expectedType);
+int esxVI_ManagedObjectReference_CastFromAnyType
+ (esxVI_AnyType *anyType,
+ esxVI_ManagedObjectReference **managedObjectReference);
int esxVI_ManagedObjectReference_CastListFromAnyType
(esxVI_AnyType *anyType,
- esxVI_ManagedObjectReference **managedObjectReferenceList,
- const char *expectedType);
+ esxVI_ManagedObjectReference **managedObjectReferenceList);
int esxVI_ManagedObjectReference_Serialize
(esxVI_ManagedObjectReference *managedObjectReference,
const char *element, virBufferPtr output);
@@ -469,833 +290,10 @@ int esxVI_ManagedObjectReference_SerializeList
(esxVI_ManagedObjectReference *managedObjectReference,
const char *element, virBufferPtr output);
int esxVI_ManagedObjectReference_Deserialize
- (xmlNodePtr node, esxVI_ManagedObjectReference **managedObjectReference,
- const char *expectedType);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: DynamicProperty
- */
-
-struct _esxVI_DynamicProperty {
- esxVI_DynamicProperty *_next; /* optional */
-
- char *name; /* required */
- esxVI_AnyType *val; /* required */
-};
-
-int esxVI_DynamicProperty_Alloc(esxVI_DynamicProperty **dynamicProperty);
-void esxVI_DynamicProperty_Free
- (esxVI_DynamicProperty **dynamicPropertyList);
-int esxVI_DynamicProperty_Validate(esxVI_DynamicProperty *dynamicProperty);
-int esxVI_DynamicProperty_DeepCopy(esxVI_DynamicProperty **dest,
- esxVI_DynamicProperty *src);
-int esxVI_DynamicProperty_DeepCopyList(esxVI_DynamicProperty **destList,
- esxVI_DynamicProperty *srcList);
-int esxVI_DynamicProperty_AppendToList
- (esxVI_DynamicProperty **dynamicPropertyList,
- esxVI_DynamicProperty *dynamicProperty);
-int esxVI_DynamicProperty_Deserialize(xmlNodePtr node,
- esxVI_DynamicProperty **dynamicProperty);
-int esxVI_DynamicProperty_DeserializeList
- (xmlNodePtr node, esxVI_DynamicProperty **dynamicPropertyList);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: HostCpuIdInfo
- */
-
-struct _esxVI_HostCpuIdInfo {
- esxVI_HostCpuIdInfo *_next; /* optional */
-
- esxVI_Int *level; /* required */
- char *vendor; /* optional */
- char *eax; /* optional */
- char *ebx; /* optional */
- char *ecx; /* optional */
- char *edx; /* optional */
-};
-
-int esxVI_HostCpuIdInfo_Alloc(esxVI_HostCpuIdInfo **hostCpuIdInfo);
-void esxVI_HostCpuIdInfo_Free(esxVI_HostCpuIdInfo **hostCpuIdInfoList);
-int esxVI_HostCpuIdInfo_Validate(esxVI_HostCpuIdInfo *hostCpuIdInfo);
-int esxVI_HostCpuIdInfo_CastFromAnyType(esxVI_AnyType *anyType,
- esxVI_HostCpuIdInfo **hostCpuIdInfo);
-int esxVI_HostCpuIdInfo_CastListFromAnyType
- (esxVI_AnyType *anyType, esxVI_HostCpuIdInfo **hostCpuIdInfoList);
-int esxVI_HostCpuIdInfo_Deserialize(xmlNodePtr node,
- esxVI_HostCpuIdInfo **hostCpuIdInfo);
-int esxVI_HostCpuIdInfo_DeserializeList
- (xmlNodePtr node, esxVI_HostCpuIdInfo **hostCpuIdInfoList);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: SelectionSpec
- */
-
-struct _esxVI_SelectionSpec {
- esxVI_SelectionSpec *_next; /* optional */
- esxVI_TraversalSpec *_super; /* optional */
-
- char *name; /* optional */
-};
-
-int esxVI_SelectionSpec_Alloc(esxVI_SelectionSpec **selectionSpec);
-void esxVI_SelectionSpec_Free(esxVI_SelectionSpec **selectionSpecList);
-int esxVI_SelectionSpec_Validate(esxVI_SelectionSpec *selectionSpec);
-int esxVI_SelectionSpec_AppendToList(esxVI_SelectionSpec **selectionSpecList,
- esxVI_SelectionSpec *selectionSpec);
-int esxVI_SelectionSpec_Serialize(esxVI_SelectionSpec *selectionSpec,
- const char *element, virBufferPtr output);
-int esxVI_SelectionSpec_SerializeList(esxVI_SelectionSpec *selectionSpecList,
- const char *element, virBufferPtr output);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: TraversalSpec extends SelectionSpec
- */
-
-struct _esxVI_TraversalSpec {
- esxVI_SelectionSpec *_base; /* required */
-
- char *type; /* required */
- char *path; /* required */
- esxVI_Boolean skip; /* optional */
- esxVI_SelectionSpec *selectSet; /* optional, list */
-};
-
-int esxVI_TraversalSpec_Alloc(esxVI_TraversalSpec **traversalSpec);
-void esxVI_TraversalSpec_Free(esxVI_TraversalSpec **traversalSpec);
-int esxVI_TraversalSpec_Validate(esxVI_TraversalSpec *traversalSpec);
-int esxVI_TraversalSpec_Serialize(esxVI_TraversalSpec *traversalSpec,
- const char *element, virBufferPtr output);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: ObjectSpec
- */
-
-struct _esxVI_ObjectSpec {
- esxVI_ObjectSpec *_next; /* optional */
-
- esxVI_ManagedObjectReference *obj; /* required */
- esxVI_Boolean skip; /* optional */
- esxVI_SelectionSpec *selectSet; /* optional, list */
-};
-
-int esxVI_ObjectSpec_Alloc(esxVI_ObjectSpec **objectSpec);
-void esxVI_ObjectSpec_Free(esxVI_ObjectSpec **objectSpecList);
-int esxVI_ObjectSpec_Validate(esxVI_ObjectSpec *objectSpec);
-int esxVI_ObjectSpec_AppendToList(esxVI_ObjectSpec **objectSpecList,
- esxVI_ObjectSpec *objectSpec);
-int esxVI_ObjectSpec_Serialize(esxVI_ObjectSpec *objectSpec,
- const char *element, virBufferPtr output);
-int esxVI_ObjectSpec_SerializeList(esxVI_ObjectSpec *objectSpecList,
- const char *element, virBufferPtr output);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: PropertyChange
- */
-
-struct _esxVI_PropertyChange {
- esxVI_PropertyChange *_next; /* optional */
-
- char *name; /* required */
- esxVI_PropertyChangeOp op; /* required */
- esxVI_AnyType *val; /* optional */
-};
-
-int esxVI_PropertyChange_Alloc(esxVI_PropertyChange **propertyChange);
-void esxVI_PropertyChange_Free(esxVI_PropertyChange **propertyChangeList);
-int esxVI_PropertyChange_Validate(esxVI_PropertyChange *propertyChange);
-int esxVI_PropertyChange_AppendToList
- (esxVI_PropertyChange **propertyChangeList,
- esxVI_PropertyChange *propertyChange);
-int esxVI_PropertyChange_Deserialize(xmlNodePtr node,
- esxVI_PropertyChange **propertyChange);
-int esxVI_PropertyChange_DeserializeList
- (xmlNodePtr node, esxVI_PropertyChange **propertyChangeList);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: PropertySpec
- */
-
-struct _esxVI_PropertySpec {
- esxVI_PropertySpec *_next; /* optional */
-
- char *type; /* required */
- esxVI_Boolean all; /* optional */
- esxVI_String *pathSet; /* optional, list */
-};
-
-int esxVI_PropertySpec_Alloc(esxVI_PropertySpec **propertySpec);
-void esxVI_PropertySpec_Free(esxVI_PropertySpec **propertySpecList);
-int esxVI_PropertySpec_Validate(esxVI_PropertySpec *propertySpec);
-int esxVI_PropertySpec_AppendToList(esxVI_PropertySpec **propertySpecList,
- esxVI_PropertySpec *propertySpec);
-int esxVI_PropertySpec_Serialize(esxVI_PropertySpec *propertySpec,
- const char *element, virBufferPtr output);
-int esxVI_PropertySpec_SerializeList(esxVI_PropertySpec *propertySpecList,
- const char *element, virBufferPtr output);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: PropertyFilterSpec
- */
-
-struct _esxVI_PropertyFilterSpec {
- esxVI_PropertyFilterSpec *_next; /* optional */
-
- esxVI_PropertySpec *propSet; /* required, list */
- esxVI_ObjectSpec *objectSet; /* required, list */
-};
-
-int esxVI_PropertyFilterSpec_Alloc
- (esxVI_PropertyFilterSpec **propertyFilterSpec);
-void esxVI_PropertyFilterSpec_Free
- (esxVI_PropertyFilterSpec **propertyFilterSpecList);
-int esxVI_PropertyFilterSpec_Validate
- (esxVI_PropertyFilterSpec *propertyFilterSpec);
-int esxVI_PropertyFilterSpec_AppendToList
- (esxVI_PropertyFilterSpec **propertyFilterSpecList,
- esxVI_PropertyFilterSpec *propertyFilterSpec);
-int esxVI_PropertyFilterSpec_Serialize
- (esxVI_PropertyFilterSpec *propertyFilterSpec, const char *element,
- virBufferPtr output);
-int esxVI_PropertyFilterSpec_SerializeList
- (esxVI_PropertyFilterSpec *propertyFilterSpecList, const char *element,
- virBufferPtr output);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: ObjectContent
- */
-
-struct _esxVI_ObjectContent {
- esxVI_ObjectContent *_next; /* optional */
-
- esxVI_ManagedObjectReference *obj; /* required */
- esxVI_DynamicProperty *propSet; /* optional, list */
- /*esxVI_MissingProperty *missingSet; *//* optional, list *//* FIXME */
-};
-
-int esxVI_ObjectContent_Alloc(esxVI_ObjectContent **objectContent);
-void esxVI_ObjectContent_Free(esxVI_ObjectContent **objectContentList);
-int esxVI_ObjectContent_Validate(esxVI_ObjectContent *objectContent);
-int esxVI_ObjectContent_AppendToList(esxVI_ObjectContent **objectContentList,
- esxVI_ObjectContent *objectContent);
-int esxVI_ObjectContent_DeepCopy(esxVI_ObjectContent **dest,
- esxVI_ObjectContent *src);
-int esxVI_ObjectContent_Deserialize(xmlNodePtr node,
- esxVI_ObjectContent **objectContent);
-int esxVI_ObjectContent_DeserializeList
- (xmlNodePtr node, esxVI_ObjectContent **objectContentList);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: ObjectUpdate
- */
-
-struct _esxVI_ObjectUpdate {
- esxVI_ObjectUpdate *_next; /* optional */
-
- esxVI_ObjectUpdateKind kind; /* required */
- esxVI_ManagedObjectReference *obj; /* required */
- esxVI_PropertyChange *changeSet; /* optional, list */
- /*esxVI_MissingProperty *missingSet; *//* optional, list *//* FIXME */
-};
-
-int esxVI_ObjectUpdate_Alloc(esxVI_ObjectUpdate **objectUpdate);
-void esxVI_ObjectUpdate_Free(esxVI_ObjectUpdate **objectUpdateList);
-int esxVI_ObjectUpdate_Validate(esxVI_ObjectUpdate *objectUpdate);
-int esxVI_ObjectUpdate_AppendToList(esxVI_ObjectUpdate **objectUpdateList,
- esxVI_ObjectUpdate *objectUpdate);
-int esxVI_ObjectUpdate_Deserialize(xmlNodePtr node,
- esxVI_ObjectUpdate **objectUpdate);
-int esxVI_ObjectUpdate_DeserializeList(xmlNodePtr node,
- esxVI_ObjectUpdate **objectUpdateList);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: PropertyFilterUpdate
- */
-
-struct _esxVI_PropertyFilterUpdate {
- esxVI_PropertyFilterUpdate *_next; /* optional */
-
- esxVI_ManagedObjectReference *filter; /* required */
- esxVI_ObjectUpdate *objectSet; /* optional, list */
- /*esxVI_MissingProperty *missingSet; *//* optional, list *//* FIXME */
-};
-
-int esxVI_PropertyFilterUpdate_Alloc
- (esxVI_PropertyFilterUpdate **propertyFilterUpdate);
-void esxVI_PropertyFilterUpdate_Free
- (esxVI_PropertyFilterUpdate **propertyFilterUpdateList);
-int esxVI_PropertyFilterUpdate_Validate
- (esxVI_PropertyFilterUpdate *propertyFilterUpdate);
-int esxVI_PropertyFilterUpdate_AppendToList
- (esxVI_PropertyFilterUpdate **propertyFilterUpdateList,
- esxVI_PropertyFilterUpdate *propertyFilterUpdate);
-int esxVI_PropertyFilterUpdate_Deserialize
- (xmlNodePtr node, esxVI_PropertyFilterUpdate **propertyFilterUpdate);
-int esxVI_PropertyFilterUpdate_DeserializeList
- (xmlNodePtr node, esxVI_PropertyFilterUpdate **propertyFilterUpdateList);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: AboutInfo
- */
-
-struct _esxVI_AboutInfo {
- char *name; /* required */
- char *fullName; /* required */
- char *vendor; /* required */
- char *version; /* required */
- char *build; /* required */
- char *localeVersion; /* optional */
- char *localeBuild; /* optional */
- char *osType; /* required */
- char *productLineId; /* required */
- char *apiType; /* required */
- char *apiVersion; /* required */
-};
-
-int esxVI_AboutInfo_Alloc(esxVI_AboutInfo **aboutInfo);
-void esxVI_AboutInfo_Free(esxVI_AboutInfo **aboutInfo);
-int esxVI_AboutInfo_Validate(esxVI_AboutInfo *aboutInfo);
-int esxVI_AboutInfo_Deserialize(xmlNodePtr node, esxVI_AboutInfo **aboutInfo);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: ServiceContent
- */
-
-struct _esxVI_ServiceContent {
- esxVI_ManagedObjectReference *rootFolder; /* required */
- esxVI_ManagedObjectReference *propertyCollector; /* required */
- esxVI_ManagedObjectReference *viewManager; /* optional */
- esxVI_AboutInfo *about; /* required */
- esxVI_ManagedObjectReference *setting; /* optional */
- esxVI_ManagedObjectReference *userDirectory; /* optional */
- esxVI_ManagedObjectReference *sessionManager; /* optional */
- esxVI_ManagedObjectReference *authorizationManager; /* optional */
- esxVI_ManagedObjectReference *perfManager; /* optional */
- esxVI_ManagedObjectReference *scheduledTaskManager; /* optional */
- esxVI_ManagedObjectReference *alarmManager; /* optional */
- esxVI_ManagedObjectReference *eventManager; /* optional */
- esxVI_ManagedObjectReference *taskManager; /* optional */
- esxVI_ManagedObjectReference *extensionManager; /* optional */
- esxVI_ManagedObjectReference *customizationSpecManager; /* optional */
- esxVI_ManagedObjectReference *customFieldsManager; /* optional */
- esxVI_ManagedObjectReference *accountManager; /* optional */
- esxVI_ManagedObjectReference *diagnosticManager; /* optional */
- esxVI_ManagedObjectReference *licenseManager; /* optional */
- esxVI_ManagedObjectReference *searchIndex; /* optional */
- esxVI_ManagedObjectReference *fileManager; /* optional */
- esxVI_ManagedObjectReference *virtualDiskManager; /* optional */
- esxVI_ManagedObjectReference *virtualizationManager; /* optional */
-};
-
-int esxVI_ServiceContent_Alloc(esxVI_ServiceContent **serviceContent);
-void esxVI_ServiceContent_Free(esxVI_ServiceContent **serviceContent);
-int esxVI_ServiceContent_Validate(esxVI_ServiceContent *serviceContent);
-int esxVI_ServiceContent_Deserialize(xmlNodePtr node,
- esxVI_ServiceContent **serviceContent);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: UpdateSet
- */
-
-struct _esxVI_UpdateSet {
- char *version; /* required */
- esxVI_PropertyFilterUpdate *filterSet; /* optional, list */
-};
-
-int esxVI_UpdateSet_Alloc(esxVI_UpdateSet **updateSet);
-void esxVI_UpdateSet_Free(esxVI_UpdateSet **updateSet);
-int esxVI_UpdateSet_Validate(esxVI_UpdateSet *updateSet);
-int esxVI_UpdateSet_Deserialize(xmlNodePtr node, esxVI_UpdateSet **updateSet);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: SharesInfo
- */
-
-struct _esxVI_SharesInfo {
- esxVI_Int *shares; /* required */
- esxVI_SharesLevel level; /* required */
-};
-
-int esxVI_SharesInfo_Alloc(esxVI_SharesInfo **sharesInfo);
-void esxVI_SharesInfo_Free(esxVI_SharesInfo **sharesInfo);
-int esxVI_SharesInfo_Validate(esxVI_SharesInfo *sharesInfo);
-int esxVI_SharesInfo_CastFromAnyType(esxVI_AnyType *anyType,
- esxVI_SharesInfo **sharesInfo);
-int esxVI_SharesInfo_Deserialize(xmlNodePtr node,
- esxVI_SharesInfo **sharesInfo);
-int esxVI_SharesInfo_Serialize(esxVI_SharesInfo *sharesInfo,
- const char *element, virBufferPtr output);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: ResourceAllocationInfo
- */
-
-struct _esxVI_ResourceAllocationInfo {
- esxVI_Long *reservation; /* optional */
- esxVI_Boolean expandableReservation; /* optional */
- esxVI_Long *limit; /* optional */
- esxVI_SharesInfo *shares; /* optional */
- esxVI_Long *overheadLimit; /* optional */
-};
-
-int esxVI_ResourceAllocationInfo_Alloc
- (esxVI_ResourceAllocationInfo **resourceAllocationInfo);
-void esxVI_ResourceAllocationInfo_Free
- (esxVI_ResourceAllocationInfo **resourceAllocationInfo);
-int esxVI_ResourceAllocationInfo_Validate
- (esxVI_ResourceAllocationInfo *resourceAllocationInfo);
-int esxVI_ResourceAllocationInfo_Serialize
- (esxVI_ResourceAllocationInfo *resourceAllocationInfo,
- const char *element, virBufferPtr output);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: ResourcePoolResourceUsage
- */
-
-struct _esxVI_ResourcePoolResourceUsage {
- esxVI_Long *reservationUsed; /* required */
- esxVI_Long *reservationUsedForVm; /* required */
- esxVI_Long *unreservedForPool; /* required */
- esxVI_Long *unreservedForVm; /* required */
- esxVI_Long *overallUsage; /* required */
- esxVI_Long *maxUsage; /* required */
-};
-
-int esxVI_ResourcePoolResourceUsage_Alloc
- (esxVI_ResourcePoolResourceUsage **resourcePoolResourceUsage);
-void esxVI_ResourcePoolResourceUsage_Free
- (esxVI_ResourcePoolResourceUsage **resourcePoolResourceUsage);
-int esxVI_ResourcePoolResourceUsage_Validate
- (esxVI_ResourcePoolResourceUsage *resourcePoolResourceUsage);
-int esxVI_ResourcePoolResourceUsage_CastFromAnyType
- (esxVI_AnyType *anyType,
- esxVI_ResourcePoolResourceUsage **resourcePoolResourceUsage);
-int esxVI_ResourcePoolResourceUsage_Deserialize
- (xmlNodePtr node,
- esxVI_ResourcePoolResourceUsage **resourcePoolResourceUsage);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: VirtualMachineConfigSpec
- */
-
-/* FIXME: implement the rest */
-struct _esxVI_VirtualMachineConfigSpec {
- char *changeVersion; /* optional */
- char *name; /* optional */
- char *version; /* optional */
- char *uuid; /* optional */
- esxVI_Long *npivNodeWorldWideName; /* optional, list */
- esxVI_Long *npivPortWorldWideName; /* optional, list */
- char *npivWorldWideNameType; /* optional */
- char *npivWorldWideNameOp; /* optional */
- char *locationId; /* optional */
- char *guestId; /* optional */
- char *alternateGuestName; /* optional */
- char *annotation; /* optional */
- //esxVI_VirtualMachineFileInfo *files; /* optional */
- //esxVI_ToolsConfigInfo *tools; /* optional */
- //esxVI_VirtualMachineFlagInfo *flags; /* optional */
- //esxVI_VirtualMachineConsolePreferences *consolePreferences; /* optional */
- //esxVI_VirtualMachineDefaultPowerOpInfo *powerOpInfo; /* optional */
- esxVI_Int *numCPUs; /* optional */
- esxVI_Long *memoryMB; /* optional */
- //esxVI_VirtualDeviceConfigSpec *deviceChange; /* optional, list */
- esxVI_ResourceAllocationInfo *cpuAllocation; /* optional */
- esxVI_ResourceAllocationInfo *memoryAllocation; /* optional */
- //esxVI_VirtualMachineAffinityInfo *cpuAffinity; /* optional */
- //esxVI_VirtualMachineAffinityInfo *memoryAffinity; /* optional */
- //esxVI_VirtualMachineNetworkShaperInfo *networkShaper; /* optional */
- //esxVI_VirtualMachineCpuIdInfoSpec *cpuFeatureMask; /* optional, list */
- //esxVI_OptionValue *extraConfig; /* optional, list */
- char *swapPlacement; /* optional */
- //esxVI_VirtualMachineBootOptions *bootOptions; /* optional */
-};
-
-int esxVI_VirtualMachineConfigSpec_Alloc
- (esxVI_VirtualMachineConfigSpec **virtualMachineConfigSpec);
-void esxVI_VirtualMachineConfigSpec_Free
- (esxVI_VirtualMachineConfigSpec **virtualMachineConfigSpec);
-int esxVI_VirtualMachineConfigSpec_Validate
- (esxVI_VirtualMachineConfigSpec *virtualMachineConfigSpec);
-int esxVI_VirtualMachineConfigSpec_Serialize
- (esxVI_VirtualMachineConfigSpec *virtualMachineConfigSpec,
- const char *element, virBufferPtr output);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: Event
- */
-
-/* FIXME: implement the rest */
-struct _esxVI_Event {
- esxVI_Event *_next; /* optional */
-
- esxVI_Int *key; /* required */
- esxVI_Int *chainId; /* required */
- esxVI_DateTime *createdTime; /* required */
- char *userName; /* required */
- //??? datacenter; /* optional */
- //??? computeResource; /* optional */
- //??? host; /* optional */
- //??? vm; /* optional */
- char *fullFormattedMessage; /* optional */
-};
-
-int esxVI_Event_Alloc(esxVI_Event **event);
-void esxVI_Event_Free(esxVI_Event **eventList);
-int esxVI_Event_Validate(esxVI_Event *event);
-int esxVI_Event_Deserialize(xmlNodePtr node, esxVI_Event **event);
-int esxVI_Event_DeserializeList(xmlNodePtr node, esxVI_Event **eventList);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: UserSession
- */
-
-struct _esxVI_UserSession {
- char *key; /* required */
- char *userName; /* required */
- char *fullName; /* required */
- esxVI_DateTime *loginTime; /* required */
- esxVI_DateTime *lastActiveTime; /* required */
- char *locale; /* required */
- char *messageLocale; /* required */
-};
-
-int esxVI_UserSession_Alloc(esxVI_UserSession **userSession);
-void esxVI_UserSession_Free(esxVI_UserSession **userSession);
-int esxVI_UserSession_Validate(esxVI_UserSession *userSession);
-int esxVI_UserSession_CastFromAnyType(esxVI_AnyType *anyType,
- esxVI_UserSession **userSession);
-int esxVI_UserSession_Deserialize(xmlNodePtr node,
- esxVI_UserSession **userSession);
-
+ (xmlNodePtr node, esxVI_ManagedObjectReference **managedObjectReference);
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: VirtualMachineQuestionInfo
- */
-
-/* FIXME: implement the rest */
-struct _esxVI_VirtualMachineQuestionInfo {
- char *id; /* required */
- char *text; /* required */
- esxVI_ChoiceOption *choice; /* required */
- /*esxVI_VirtualMachineMessage *message;*/ /* optional, list */
-};
-
-int esxVI_VirtualMachineQuestionInfo_Alloc
- (esxVI_VirtualMachineQuestionInfo **virtualMachineQuestionInfo);
-void esxVI_VirtualMachineQuestionInfo_Free
- (esxVI_VirtualMachineQuestionInfo **virtualMachineQuestionInfo);
-int esxVI_VirtualMachineQuestionInfo_Validate
- (esxVI_VirtualMachineQuestionInfo *virtualMachineQuestionInfo);
-int esxVI_VirtualMachineQuestionInfo_CastFromAnyType
- (esxVI_AnyType *anyType,
- esxVI_VirtualMachineQuestionInfo **virtualMachineQuestionInfo);
-int esxVI_VirtualMachineQuestionInfo_Deserialize
- (xmlNodePtr node,
- esxVI_VirtualMachineQuestionInfo **virtualMachineQuestionInfo);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: ElementDescription extends Description
- *
- * In contrast to SelectionSpec and TraversalSpec just merge
- * Description into ElementDescription for simplicity, because
- * only ElementDescription is used.
- */
-
-struct _esxVI_ElementDescription {
- esxVI_ElementDescription *_next; /* optional */
-
- /* Description */
- char *label; /* required */
- char *summary; /* required */
-
- /* ElementDescription */
- char *key; /* required */
-};
-
-int esxVI_ElementDescription_Alloc
- (esxVI_ElementDescription **elementDescription);
-void esxVI_ElementDescription_Free
- (esxVI_ElementDescription **elementDescription);
-int esxVI_ElementDescription_Validate
- (esxVI_ElementDescription *elementDescription);
-int esxVI_ElementDescription_AppendToList
- (esxVI_ElementDescription **elementDescriptionList,
- esxVI_ElementDescription *elementDescription);
-int esxVI_ElementDescription_Deserialize
- (xmlNodePtr node, esxVI_ElementDescription **elementDescription);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: ChoiceOption extends OptionType
- *
- * In contrast to SelectionSpec and TraversalSpec just merge
- * OptionType into ChoiceOption for simplicity, because
- * only ChoiceOption is used.
- */
-
-struct _esxVI_ChoiceOption {
- /* OptionType */
- esxVI_Boolean valueIsReadonly; /* optional */
-
- /* ChoiceOption */
- esxVI_ElementDescription *choiceInfo; /* required, list */
- esxVI_Int *defaultIndex; /* optional */
-};
-
-int esxVI_ChoiceOption_Alloc(esxVI_ChoiceOption **choiceOption);
-void esxVI_ChoiceOption_Free(esxVI_ChoiceOption **choiceOption);
-int esxVI_ChoiceOption_Validate(esxVI_ChoiceOption *choiceOption);
-int esxVI_ChoiceOption_Deserialize(xmlNodePtr node,
- esxVI_ChoiceOption **choiceOption);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: PerfMetricId
- */
-
-struct _esxVI_PerfMetricId {
- esxVI_PerfMetricId *_next; /* optional */
-
- esxVI_Int *counterId; /* required */
- char *instance; /* required */
-};
-
-int esxVI_PerfMetricId_Alloc(esxVI_PerfMetricId **perfMetricId);
-void esxVI_PerfMetricId_Free(esxVI_PerfMetricId **perfMetricId);
-int esxVI_PerfMetricId_Validate(esxVI_PerfMetricId *perfMetricId);
-int esxVI_PerfMetricId_Serialize(esxVI_PerfMetricId *perfMetricId,
- const char *element, virBufferPtr output);
-int esxVI_PerfMetricId_SerializeList(esxVI_PerfMetricId *perfMetricIdList,
- const char *element, virBufferPtr output);
-int esxVI_PerfMetricId_Deserialize(xmlNodePtr node,
- esxVI_PerfMetricId **perfMetricId);
-int esxVI_PerfMetricId_DeserializeList(xmlNodePtr node,
- esxVI_PerfMetricId **perfMetricIdList);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: PerfCounterInfo
- */
-
-struct _esxVI_PerfCounterInfo {
- esxVI_PerfCounterInfo *_next; /* optional */
-
- esxVI_Int *key; /* required */
- esxVI_ElementDescription *nameInfo; /* required */
- esxVI_ElementDescription *groupInfo; /* required */
- esxVI_ElementDescription *unitInfo; /* required */
- esxVI_PerfSummaryType rollupType; /* required */
- esxVI_PerfStatsType statsType; /* required */
- esxVI_Int *level; /* optional */
- esxVI_Int *associatedCounterId; /* optional, list */
-};
-
-int esxVI_PerfCounterInfo_Alloc(esxVI_PerfCounterInfo **perfCounterInfo);
-void esxVI_PerfCounterInfo_Free(esxVI_PerfCounterInfo **perfCounterInfo);
-int esxVI_PerfCounterInfo_Validate(esxVI_PerfCounterInfo *perfCounterInfo);
-int esxVI_PerfCounterInfo_Deserialize(xmlNodePtr node,
- esxVI_PerfCounterInfo **perfCounterInfo);
-int esxVI_PerfCounterInfo_DeserializeList
- (xmlNodePtr node, esxVI_PerfCounterInfo **perfCounterInfoList);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: PerfQuerySpec
- */
-
-struct _esxVI_PerfQuerySpec {
- esxVI_PerfQuerySpec *_next; /* optional */
-
- esxVI_ManagedObjectReference *entity; /* required */
- esxVI_DateTime *startTime; /* optional */
- esxVI_DateTime *endTime; /* optional */
- esxVI_Int *maxSample; /* optional */
- esxVI_PerfMetricId *metricId; /* optional, list */
- esxVI_Int *intervalId; /* optional */
- char *format; /* optional */ // FIXME: see PerfFormat
-};
-
-int esxVI_PerfQuerySpec_Alloc(esxVI_PerfQuerySpec **perfQuerySpec);
-void esxVI_PerfQuerySpec_Free(esxVI_PerfQuerySpec **perfQuerySpec);
-int esxVI_PerfQuerySpec_Validate(esxVI_PerfQuerySpec *perfQuerySpec);
-int esxVI_PerfQuerySpec_Serialize(esxVI_PerfQuerySpec *perfQuerySpec,
- const char *element, virBufferPtr output);
-int esxVI_PerfQuerySpec_SerializeList(esxVI_PerfQuerySpec *perfQuerySpecList,
- const char *element, virBufferPtr output);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: PerfSampleInfo
- */
-
-struct _esxVI_PerfSampleInfo {
- esxVI_PerfSampleInfo *_next; /* optional */
-
- esxVI_DateTime *timestamp; /* required */
- esxVI_Int *interval; /* required */
-};
-
-int esxVI_PerfSampleInfo_Alloc(esxVI_PerfSampleInfo **perfSampleInfo);
-void esxVI_PerfSampleInfo_Free(esxVI_PerfSampleInfo **perfSampleInfo);
-int esxVI_PerfSampleInfo_Validate(esxVI_PerfSampleInfo *perfSampleInfo);
-int esxVI_PerfSampleInfo_AppendToList(esxVI_PerfSampleInfo **perfSampleInfoList,
- esxVI_PerfSampleInfo *perfSampleInfo);
-int esxVI_PerfSampleInfo_Deserialize(xmlNodePtr node,
- esxVI_PerfSampleInfo **perfSampleInfo);
-int esxVI_PerfSampleInfo_DeserializeList
- (xmlNodePtr node, esxVI_PerfSampleInfo **perfSampleInfoList);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: PerfMetricIntSeries extends PerfMetricSeries
- *
- * In contrast to SelectionSpec and TraversalSpec just merge
- * PerfMetricSeries into PerfMetricIntSeries for simplicity, because
- * only PerfMetricIntSeries is used and the other type inheriting
- * PerfMetricSeries (PerfMetricSeriesCSV) is not used.
- */
-
-struct _esxVI_PerfMetricIntSeries {
- esxVI_PerfMetricIntSeries *_next; /* optional */
-
- /* PerfMetricSeries */
- esxVI_PerfMetricId *id; /* required */
-
- /* PerfMetricIntSeries */
- esxVI_Long *value; /* optional, list */
-};
-
-int esxVI_PerfMetricIntSeries_Alloc
- (esxVI_PerfMetricIntSeries **perfMetricIntSeries);
-void esxVI_PerfMetricIntSeries_Free
- (esxVI_PerfMetricIntSeries **perfMetricIntSeries);
-int esxVI_PerfMetricIntSeries_Validate
- (esxVI_PerfMetricIntSeries *perfMetricIntSeries);
-int esxVI_PerfMetricIntSeries_AppendToList
- (esxVI_PerfMetricIntSeries **perfMetricIntSeriesList,
- esxVI_PerfMetricIntSeries *perfMetricIntSeries);
-int esxVI_PerfMetricIntSeries_Deserialize
- (xmlNodePtr node, esxVI_PerfMetricIntSeries **perfMetricIntSeries);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: PerfEntityMetric extends PerfEntityMetricBase
- *
- * In contrast to SelectionSpec and TraversalSpec just merge
- * PerfEntityMetricBase into PerfEntityMetric for simplicity, because
- * only PerfEntityMetric is used and the other type inheriting
- * PerfEntityMetric (PerfEntityMetricCSV) is not used.
- *
- * Also use PerfMetricIntSeries instead of the correct base type
- * PerfMetricSeries for the value property, because only
- * PerfMetricIntSeries is used.
- */
-
-struct _esxVI_PerfEntityMetric {
- esxVI_PerfEntityMetric *_next; /* optional */
-
- /* PerfEntityMetricBase */
- esxVI_ManagedObjectReference *entity; /* required */
-
- /* PerfEntityMetric */
- esxVI_PerfSampleInfo *sampleInfo; /* optional, list */
- esxVI_PerfMetricIntSeries *value; /* optional, list */
-};
-
-int esxVI_PerfEntityMetric_Alloc(esxVI_PerfEntityMetric **perfEntityMetric);
-void esxVI_PerfEntityMetric_Free(esxVI_PerfEntityMetric **perfEntityMetric);
-int esxVI_PerfEntityMetric_Validate(esxVI_PerfEntityMetric *perfEntityMetric);
-int esxVI_PerfEntityMetric_Deserialize
- (xmlNodePtr node, esxVI_PerfEntityMetric **perfEntityMetric);
-int esxVI_PerfEntityMetric_DeserializeList
- (xmlNodePtr node, esxVI_PerfEntityMetric **perfEntityMetricList);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: TaskInfo
- */
-
-struct _esxVI_TaskInfo {
- esxVI_TaskInfo *_next; /* optional */
-
- char *key; /* required */
- esxVI_ManagedObjectReference *task; /* required */
- char *name; /* optional */
- char *descriptionId; /* required */
- esxVI_ManagedObjectReference *entity; /* optional */
- char *entityName; /* optional */
- /*esxVI_ManagedObjectReference *locked;*/ /* optional, list *//* FIXME */
- esxVI_TaskInfoState state; /* required */
- esxVI_Boolean cancelled; /* required */
- esxVI_Boolean cancelable; /* required */
- /*esxVI_MethodFault *error;*/ /* optional *//* FIXME */
- esxVI_AnyType *result; /* optional */
- esxVI_Int *progress; /* optional */
- /*esxVI_TaskReason *reason;*/ /* required *//* FIXME */
- esxVI_DateTime *queueTime; /* required */
- esxVI_DateTime *startTime; /* optional */
- esxVI_DateTime *completeTime; /* optional */
- esxVI_Int *eventChainId; /* required */
-};
-int esxVI_TaskInfo_Alloc(esxVI_TaskInfo **taskInfo);
-void esxVI_TaskInfo_Free(esxVI_TaskInfo **taskInfoList);
-int esxVI_TaskInfo_Validate(esxVI_TaskInfo *taskInfo);
-int esxVI_TaskInfo_CastFromAnyType(esxVI_AnyType *anyType,
- esxVI_TaskInfo **taskInfo);
-int esxVI_TaskInfo_AppendToList(esxVI_TaskInfo **taskInfoList,
- esxVI_TaskInfo *taskInfo);
-int esxVI_TaskInfo_Deserialize(xmlNodePtr node, esxVI_TaskInfo **taskInfo);
+#include "esx_vi_types.generated.h"
#endif /* __ESX_VI_TYPES_H__ */
--
1.6.3.3
2
2
31 Mar '10
2010/3/31 Daniel Veillard <veillard(a)redhat.com>:
> On Wed, Mar 31, 2010 at 01:38:48PM +0200, Matthias Bolte wrote:
>> ---
>> src/.gitignore | 1 +
>> tests/.gitignore | 1 +
>> 2 files changed, 2 insertions(+), 0 deletions(-)
>>
>> diff --git a/src/.gitignore b/src/.gitignore
>> index 26b8689..e407dcb 100644
>> --- a/src/.gitignore
>> +++ b/src/.gitignore
>> @@ -15,3 +15,4 @@ libvirt_lxc
>> libvirt.syms
>> *.i
>> *.s
>> +virt-aa-helper
>> diff --git a/tests/.gitignore b/tests/.gitignore
>> index 399baee..387a924 100644
>> --- a/tests/.gitignore
>> +++ b/tests/.gitignore
>> @@ -33,3 +33,4 @@ object-locking-files.txt
>> esxutilstest
>> vmx2xmltest
>> xml2vmxtest
>> +secaatest
>
> ACK,
>
> Daniel
>
Thanks, pushed.
Matthias
1
0
---
src/esx/esx_vi_types.c | 66 ++++++++++++++++++++++++------------------------
1 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index 6f257b2..3a30712 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -682,10 +682,10 @@ static const esxVI_Enumeration _esxVI_Boolean_Enumeration = {
};
/* esxVI_Boolean_Serialize */
-ESX_VI__TEMPLATE__ENUMERATION__SERIALIZE(Boolean);
+ESX_VI__TEMPLATE__ENUMERATION__SERIALIZE(Boolean)
/* esxVI_Boolean_Deserialize */
-ESX_VI__TEMPLATE__ENUMERATION__DESERIALIZE(Boolean);
+ESX_VI__TEMPLATE__ENUMERATION__DESERIALIZE(Boolean)
@@ -694,7 +694,7 @@ ESX_VI__TEMPLATE__ENUMERATION__DESERIALIZE(Boolean);
*/
/* esxVI_AnyType_Alloc */
-ESX_VI__TEMPLATE__ALLOC(AnyType);
+ESX_VI__TEMPLATE__ALLOC(AnyType)
/* esxVI_AnyType_Free */
ESX_VI__TEMPLATE__FREE(AnyType,
@@ -702,7 +702,7 @@ ESX_VI__TEMPLATE__FREE(AnyType,
xmlFreeNode(item->node);
VIR_FREE(item->other);
VIR_FREE(item->value);
-});
+})
int
esxVI_AnyType_ExpectType(esxVI_AnyType *anyType, esxVI_Type type)
@@ -908,7 +908,7 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType)
*/
/* esxVI_String_Alloc */
-ESX_VI__TEMPLATE__ALLOC(String);
+ESX_VI__TEMPLATE__ALLOC(String)
/* esxVI_String_Free */
ESX_VI__TEMPLATE__FREE(String,
@@ -916,7 +916,7 @@ ESX_VI__TEMPLATE__FREE(String,
esxVI_String_Free(&item->_next);
VIR_FREE(item->value);
-});
+})
/* esxVI_String_Validate */
ESX_VI__TEMPLATE__VALIDATE(String,
@@ -925,7 +925,7 @@ ESX_VI__TEMPLATE__VALIDATE(String,
})
/* esxVI_String_AppendToList */
-ESX_VI__TEMPLATE__LIST__APPEND(String);
+ESX_VI__TEMPLATE__LIST__APPEND(String)
int
esxVI_String_AppendValueToList(esxVI_String **stringList, const char *value)
@@ -989,7 +989,7 @@ ESX_VI__TEMPLATE__DEEP_COPY(String,
})
/* esxVI_String_DeepCopyList */
-ESX_VI__TEMPLATE__LIST__DEEP_COPY(String);
+ESX_VI__TEMPLATE__LIST__DEEP_COPY(String)
int
esxVI_String_DeepCopyValue(char **dest, const char *src)
@@ -1022,7 +1022,7 @@ esxVI_String_Serialize(esxVI_String *string, const char *element,
}
/* esxVI_String_SerializeList */
-ESX_VI__TEMPLATE__LIST__SERIALIZE(String);
+ESX_VI__TEMPLATE__LIST__SERIALIZE(String)
int
esxVI_String_SerializeValue(const char *value, const char *element,
@@ -1053,7 +1053,7 @@ ESX_VI__TEMPLATE__DESERIALIZE(String,
})
/* esxVI_String_DeserializeList */
-ESX_VI__TEMPLATE__LIST__DESERIALIZE(String);
+ESX_VI__TEMPLATE__LIST__DESERIALIZE(String)
int
esxVI_String_DeserializeValue(xmlNodePtr node, char **value)
@@ -1084,13 +1084,13 @@ esxVI_String_DeserializeValue(xmlNodePtr node, char **value)
*/
/* esxVI_Int_Alloc */
-ESX_VI__TEMPLATE__ALLOC(Int);
+ESX_VI__TEMPLATE__ALLOC(Int)
/* esxVI_Int_Free */
ESX_VI__TEMPLATE__FREE(Int,
{
esxVI_Int_Free(&item->_next);
-});
+})
/* esxVI_Int_Validate */
ESX_VI__TEMPLATE__VALIDATE(Int,
@@ -1098,7 +1098,7 @@ ESX_VI__TEMPLATE__VALIDATE(Int,
})
/* esxVI_Int_AppendToList */
-ESX_VI__TEMPLATE__LIST__APPEND(Int);
+ESX_VI__TEMPLATE__LIST__APPEND(Int)
/* esxVI_Int_DeepCopy */
ESX_VI__TEMPLATE__DEEP_COPY(Int,
@@ -1110,13 +1110,13 @@ ESX_VI__TEMPLATE__DEEP_COPY(Int,
ESX_VI__TEMPLATE__SERIALIZE(Int,
{
virBufferVSprintf(output, "%d", (int)item->value);
-});
+})
/* esxVI_Int_SerializeList */
-ESX_VI__TEMPLATE__LIST__SERIALIZE(Int);
+ESX_VI__TEMPLATE__LIST__SERIALIZE(Int)
/* esxVI_Int_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE_NUMBER(Int, "xsd:int", INT32_MIN, INT32_MAX);
+ESX_VI__TEMPLATE__DESERIALIZE_NUMBER(Int, "xsd:int", INT32_MIN, INT32_MAX)
@@ -1125,13 +1125,13 @@ ESX_VI__TEMPLATE__DESERIALIZE_NUMBER(Int, "xsd:int", INT32_MIN, INT32_MAX);
*/
/* esxVI_Long_Alloc */
-ESX_VI__TEMPLATE__ALLOC(Long);
+ESX_VI__TEMPLATE__ALLOC(Long)
/* esxVI_Long_Free */
ESX_VI__TEMPLATE__FREE(Long,
{
esxVI_Long_Free(&item->_next);
-});
+})
/* esxVI_Long_Validate */
ESX_VI__TEMPLATE__VALIDATE(Long,
@@ -1139,19 +1139,19 @@ ESX_VI__TEMPLATE__VALIDATE(Long,
})
/* esxVI_Long_AppendToList */
-ESX_VI__TEMPLATE__LIST__APPEND(Long);
+ESX_VI__TEMPLATE__LIST__APPEND(Long)
/* esxVI_Long_Serialize */
ESX_VI__TEMPLATE__SERIALIZE(Long,
{
virBufferVSprintf(output, "%lld", (long long int)item->value);
-});
+})
/* esxVI_Long_SerializeList */
-ESX_VI__TEMPLATE__LIST__SERIALIZE(Long);
+ESX_VI__TEMPLATE__LIST__SERIALIZE(Long)
/* esxVI_Long_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE_NUMBER(Long, "xsd:long", INT64_MIN, INT64_MAX);
+ESX_VI__TEMPLATE__DESERIALIZE_NUMBER(Long, "xsd:long", INT64_MIN, INT64_MAX)
@@ -1160,25 +1160,25 @@ ESX_VI__TEMPLATE__DESERIALIZE_NUMBER(Long, "xsd:long", INT64_MIN, INT64_MAX);
*/
/* esxVI_DateTime_Alloc */
-ESX_VI__TEMPLATE__ALLOC(DateTime);
+ESX_VI__TEMPLATE__ALLOC(DateTime)
/* esxVI_DateTime_Free */
ESX_VI__TEMPLATE__FREE(DateTime,
{
VIR_FREE(item->value);
-});
+})
/* esxVI_DateTime_Validate */
ESX_VI__TEMPLATE__VALIDATE(DateTime,
{
ESX_VI__TEMPLATE__PROPERTY__REQUIRE(value);
-});
+})
/* esxVI_DateTime_Serialize */
ESX_VI__TEMPLATE__SERIALIZE(DateTime,
{
virBufferAdd(output, item->value, -1);
-});
+})
int
esxVI_DateTime_Deserialize(xmlNodePtr node, esxVI_DateTime **dateTime)
@@ -1224,14 +1224,14 @@ ESX_VI__TEMPLATE__FREE(Fault,
{
VIR_FREE(item->faultcode);
VIR_FREE(item->faultstring);
-});
+})
/* esxVI_Fault_Validate */
ESX_VI__TEMPLATE__VALIDATE(Fault,
{
ESX_VI__TEMPLATE__PROPERTY__REQUIRE(faultcode);
ESX_VI__TEMPLATE__PROPERTY__REQUIRE(faultstring);
-});
+})
/* esxVI_Fault_Deserialize */
ESX_VI__TEMPLATE__DESERIALIZE(Fault,
@@ -1239,7 +1239,7 @@ ESX_VI__TEMPLATE__DESERIALIZE(Fault,
ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, faultcode);
ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, faultstring);
ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_IGNORE(detail); /* FIXME */
-});
+})
@@ -1248,7 +1248,7 @@ ESX_VI__TEMPLATE__DESERIALIZE(Fault,
*/
/* esxVI_ManagedObjectReference_Alloc */
-ESX_VI__TEMPLATE__ALLOC(ManagedObjectReference);
+ESX_VI__TEMPLATE__ALLOC(ManagedObjectReference)
/* esxVI_ManagedObjectReference_Free */
ESX_VI__TEMPLATE__FREE(ManagedObjectReference,
@@ -1257,7 +1257,7 @@ ESX_VI__TEMPLATE__FREE(ManagedObjectReference,
VIR_FREE(item->type);
VIR_FREE(item->value);
-});
+})
/* esxVI_ManagedObjectReference_DeepCopy */
ESX_VI__TEMPLATE__DEEP_COPY(ManagedObjectReference,
@@ -1267,7 +1267,7 @@ ESX_VI__TEMPLATE__DEEP_COPY(ManagedObjectReference,
})
/* esxVI_ManagedObjectReference_AppendToList */
-ESX_VI__TEMPLATE__LIST__APPEND(ManagedObjectReference);
+ESX_VI__TEMPLATE__LIST__APPEND(ManagedObjectReference)
/* esxVI_ManagedObjectReference_CastFromAnyType */
ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(ManagedObjectReference)
@@ -1304,7 +1304,7 @@ esxVI_ManagedObjectReference_Serialize
}
/* esxVI_ManagedObjectReference_SerializeList */
-ESX_VI__TEMPLATE__LIST__SERIALIZE(ManagedObjectReference);
+ESX_VI__TEMPLATE__LIST__SERIALIZE(ManagedObjectReference)
int
esxVI_ManagedObjectReference_Deserialize
--
1.6.3.3
2
2
[libvirt] [PATCH] maint: mark xenapiSessionErrorHandler messages for translation
by Jim Meyering 31 Mar '10
by Jim Meyering 31 Mar '10
31 Mar '10
This makes sure that all xenapiSessionErrorHandler diagnostics
are marked for translation.
>From c79adc5fb5efb7aa2fbeee20d41d1c765e90b022 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 31 Mar 2010 12:24:25 +0200
Subject: [PATCH] maint: mark xenapiSessionErrorHandler messages for translation
* cfg.mk (msg_gen_function): Add xenapiSessionErrorHandler.
* po/POTFILES.in: Add src/xenapi/xenapi_driver.c
* src/xenapi/xenapi_driver.c: Mark strings for translation.
* src/xenapi/xenapi_utils.c (xenapiUtil_ParseQuery):
---
cfg.mk | 1 +
po/POTFILES.in | 1 +
src/xenapi/xenapi_driver.c | 138 +++++++++++++++++++++++++++-----------------
src/xenapi/xenapi_utils.c | 2 +-
4 files changed, 89 insertions(+), 53 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 9b8ee00..45da56a 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -215,6 +215,7 @@ msg_gen_function += virXenInotifyError
msg_gen_function += virXenStoreError
msg_gen_function += virXendError
msg_gen_function += vshCloseLogFile
+msg_gen_function += xenapiSessionErrorHandler
msg_gen_function += xenUnifiedError
msg_gen_function += xenXMError
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 645c344..417bfa1 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -85,6 +85,7 @@ src/xen/xen_hypervisor.c
src/xen/xen_inotify.c
src/xen/xm_internal.c
src/xen/xs_internal.c
+src/xenapi/xenapi_driver.c
src/xenapi/xenapi_utils.c
tools/console.c
tools/virsh.c
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 6e1183d..d48bb4d 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -95,13 +95,13 @@ xenapiOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUS
if (conn->uri->server == NULL) {
xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED,
- "Server name not in URI");
+ _("Server name not in URI"));
goto error;
}
if (auth == NULL) {
xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED,
- "Authentication Credentials not found");
+ _("Authentication Credentials not found"));
goto error;
}
@@ -117,7 +117,7 @@ xenapiOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUS
if (username == NULL) {
xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED,
- "Username request failed");
+ _("Username request failed"));
goto error;
}
}
@@ -126,7 +126,7 @@ xenapiOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUS
if (password == NULL) {
xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED,
- "Password request failed");
+ _("Password request failed"));
goto error;
}
@@ -145,7 +145,7 @@ xenapiOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUS
if (!(privP->caps = getCapsObject())) {
xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
- "Capabilities not found");
+ _("Capabilities not found"));
goto error;
}
@@ -166,7 +166,7 @@ xenapiOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUS
return VIR_DRV_OPEN_SUCCESS;
}
- xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED, "");
+ xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED, NULL);
error:
VIR_FREE(username);
@@ -279,7 +279,8 @@ xenapiGetVersion (virConnectPtr conn, unsigned long *hvVer)
}
if (version) {
if (sscanf(version, "%ld.%ld.%ld", &major, &minor, &release) != 3) {
- xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Couldn't get version info");
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
+ _("Couldn't get version info"));
xen_string_string_map_free(result);
VIR_FREE(version);
return -1;
@@ -356,7 +357,8 @@ xenapiNodeGetInfo (virConnectPtr conn, virNodeInfoPtr info)
info->memory = (unsigned long)(memory / 1024);
xen_host_metrics_set_free(xen_met_set);
} else {
- xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Unable to get host metric Information");
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
+ _("Unable to get host metric Information"));
return -1;
}
if (xen_host_cpu_get_all(session, &host_cpu_set)) {
@@ -377,7 +379,8 @@ xenapiNodeGetInfo (virConnectPtr conn, virNodeInfoPtr info)
VIR_FREE(modelname);
return 0;
}
- xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Unable to get Host CPU set");
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
+ _("Unable to get Host CPU set"));
return -1;
}
@@ -397,7 +400,8 @@ xenapiGetCapabilities (virConnectPtr conn)
return xml;
}
cleanup:
- xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Capabilities not available");
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
+ _("Capabilities not available"));
return NULL;
}
@@ -426,7 +430,8 @@ xenapiListDomains (virConnectPtr conn, int *ids, int maxids)
for (i = 0; (i < (result->size)) && (i < maxids); i++) {
xen_vm_get_domid(session, &t0, result->contents[i]);
if (t0 > (int64_t)INT_MAX || t0 < (int64_t)INT_MIN) {
- xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "DomainID can't fit in 32 bits");
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
+ _("DomainID can't fit in 32 bits"));
xen_vm_set_free(result);
return -1;
}
@@ -497,7 +502,8 @@ xenapiDomainCreateXML (virConnectPtr conn,
domP = virGetDomain(conn, record->name_label, raw_uuid);
if (!domP) {
xen_vm_record_free(record);
- xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Domain Pointer is invalid");
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
+ _("Domain Pointer is invalid"));
return domP;
}
domP->id = record->domid;
@@ -549,7 +555,8 @@ xenapiDomainLookupByID (virConnectPtr conn, int id)
xen_vm_get_domid(session, &domid, result->contents[i]);
domP->id = domid;
} else {
- xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Domain Pointer not valid");
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
+ _("Domain Pointer not valid"));
domP = NULL;
}
xen_uuid_free(uuid);
@@ -590,7 +597,8 @@ xenapiDomainLookupByUUID (virConnectPtr conn,
if (record != NULL) {
domP = virGetDomain(conn, record->name_label, uuid);
if (!domP) {
- xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Domain Pointer not valid");
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
+ _("Domain Pointer not valid"));
domP = NULL;
} else {
domP->id = record->domid;
@@ -624,7 +632,8 @@ xenapiDomainLookupByName (virConnectPtr conn,
xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
if (xen_vm_get_by_name_label(session, &vms, (char *)name) && vms->size > 0) {
if (vms->size != 1) {
- xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Domain name is not unique");
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
+ _("Domain name is not unique"));
xen_vm_set_free(vms);
return NULL;
}
@@ -644,13 +653,14 @@ xenapiDomainLookupByName (virConnectPtr conn,
xen_uuid_free(uuid);
xen_vm_set_free(vms);
if (!session->ok)
- xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Couldn't get the Domain Pointer");
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
+ _("Couldn't get the Domain Pointer"));
return NULL;
}
}
}
if (vms) xen_vm_set_free(vms);
- xenapiSessionErrorHandler(conn, VIR_ERR_NO_DOMAIN, "");
+ xenapiSessionErrorHandler(conn, VIR_ERR_NO_DOMAIN, NULL);
return NULL;
}
@@ -669,7 +679,8 @@ xenapiDomainSuspend (virDomainPtr dom)
xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
if (vms->size != 1) {
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Domain name is not unique");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ _("Domain name is not unique"));
xen_vm_set_free(vms);
return -1;
} else {
@@ -684,7 +695,7 @@ xenapiDomainSuspend (virDomainPtr dom)
}
}
if (vms) xen_vm_set_free(vms);
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, "");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
return -1;
}
@@ -703,7 +714,8 @@ xenapiDomainResume (virDomainPtr dom)
xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
if (vms->size != 1) {
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Domain name is not unique");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ _("Domain name is not unique"));
xen_vm_set_free(vms);
return -1;
} else {
@@ -718,7 +730,7 @@ xenapiDomainResume (virDomainPtr dom)
}
}
if (vms) xen_vm_set_free(vms);
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, "");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
return -1;
}
@@ -737,7 +749,8 @@ xenapiDomainShutdown (virDomainPtr dom)
xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
if (vms->size != 1) {
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Domain name is not unique");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ _("Domain name is not unique"));
xen_vm_set_free(vms);
return -1;
} else {
@@ -752,7 +765,7 @@ xenapiDomainShutdown (virDomainPtr dom)
}
}
if (vms) xen_vm_set_free(vms);
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, "");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
return -1;
}
@@ -771,7 +784,8 @@ xenapiDomainReboot (virDomainPtr dom, unsigned int flags ATTRIBUTE_UNUSED)
xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
if (vms->size != 1) {
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Domain name is not unique");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ _("Domain name is not unique"));
xen_vm_set_free(vms);
return -1;
}
@@ -785,7 +799,7 @@ xenapiDomainReboot (virDomainPtr dom, unsigned int flags ATTRIBUTE_UNUSED)
return 0;
}
if (vms) xen_vm_set_free(vms);
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, "");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
return -1;
}
@@ -804,7 +818,8 @@ xenapiDomainDestroy (virDomainPtr dom)
xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
if (vms->size != 1) {
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Domain name is not unique");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ _("Domain name is not unique"));
xen_vm_set_free(vms);
return -1;
}
@@ -818,7 +833,7 @@ xenapiDomainDestroy (virDomainPtr dom)
return 0;
}
if (vms) xen_vm_set_free(vms);
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, "");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
return -1;
}
@@ -839,7 +854,8 @@ xenapiDomainGetOSType (virDomainPtr dom)
if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
if (vms->size != 1) {
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Domain name is not unique");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ _("Domain name is not unique"));
xen_vm_set_free(vms);
return NULL;
}
@@ -852,7 +868,7 @@ xenapiDomainGetOSType (virDomainPtr dom)
virReportOOMError();
VIR_FREE(boot_policy);
} else
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, "");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
cleanup:
if (vms) xen_vm_set_free(vms);
@@ -873,7 +889,8 @@ xenapiDomainGetMaxMemory (virDomainPtr dom)
xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
if (vms->size != 1) {
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Domain name is not unique");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ _("Domain name is not unique"));
xen_vm_set_free(vms);
return 0;
}
@@ -903,7 +920,8 @@ xenapiDomainSetMaxMemory (virDomainPtr dom, unsigned long memory)
xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
if (vms->size != 1) {
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Domain name is not unique");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ _("Domain name is not unique"));
xen_vm_set_free(vms);
return -1;
}
@@ -939,7 +957,8 @@ xenapiDomainGetInfo (virDomainPtr dom, virDomainInfoPtr info)
info->cpuTime = 0; /* CPU time is not advertised */
if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
if (vms->size != 1) {
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Domain name is not unique");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ _("Domain name is not unique"));
xen_vm_set_free(vms);
return -1;
}
@@ -982,7 +1001,8 @@ xenapiDomainSetVcpus (virDomainPtr dom, unsigned int nvcpus)
xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
if (vms->size != 1) {
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Domain name is not unique");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ _("Domain name is not unique"));
xen_vm_set_free(vms);
return -1;
}
@@ -1013,7 +1033,8 @@ xenapiDomainPinVcpu (virDomainPtr dom, unsigned int vcpu ATTRIBUTE_UNUSED,
xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
if (vms->size != 1) {
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Domain name is not unique");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ _("Domain name is not unique"));
xen_vm_set_free(vms);
return -1;
}
@@ -1063,13 +1084,15 @@ xenapiDomainGetVcpus (virDomainPtr dom,
if (xenapiDomainGetInfo(dom, &domInfo) == 0) {
nvcpus = domInfo.nrVirtCpu;
} else {
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Couldn't fetch Domain Information");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ _("Couldn't fetch Domain Information"));
return -1;
}
if (xenapiNodeGetInfo(dom->conn, &nodeInfo) == 0)
cpus = nodeInfo.cpus;
else {
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Couldn't fetch Node Information");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ _("Couldn't fetch Node Information"));
return -1;
}
if (nvcpus > maxinfo)
@@ -1079,7 +1102,8 @@ xenapiDomainGetVcpus (virDomainPtr dom,
if (!xen_vm_get_by_name_label(session, &vms, dom->name))
return -1;
if (vms->size != 1) {
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Domain name is not unique");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ _("Domain name is not unique"));
xen_vm_set_free(vms);
return -1;
}
@@ -1130,7 +1154,8 @@ xenapiDomainGetMaxVcpus (virDomainPtr dom)
xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
if (vms->size != 1) {
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Domain name is not unique");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ _("Domain name is not unique"));
xen_vm_set_free(vms);
return -1;
}
@@ -1166,7 +1191,8 @@ xenapiDomainDumpXML (virDomainPtr dom, int flags ATTRIBUTE_UNUSED)
if (!xen_vm_get_by_name_label(session, &vms, dom->name)) return NULL;
if (vms->size != 1) {
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Domain name is not unique");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ _("Domain name is not unique"));
xen_vm_set_free(vms);
return NULL;
}
@@ -1322,7 +1348,7 @@ xenapiDomainDumpXML (virDomainPtr dom, int flags ATTRIBUTE_UNUSED)
if (vif_rec != NULL) {
if (virParseMacAddr((const char *)vif_rec->mac,defPtr->nets[i]->mac) < 0)
xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
- "Unable to parse given mac address");
+ _("Unable to parse given mac address"));
xen_vif_record_free(vif_rec);
}
}
@@ -1373,7 +1399,8 @@ xenapiListDefinedDomains (virConnectPtr conn, char **const names,
}
xen_vm_record_free(record);
} else {
- xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Couldn't get VM record");
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
+ _("Couldn't get VM record"));
xen_vm_set_free(result);
while (--j >= 0) VIR_FREE(names[j]);
return -1;
@@ -1434,7 +1461,8 @@ xenapiDomainCreate (virDomainPtr dom)
xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
if (vms->size != 1) {
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Domain name is not unique");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ _("Domain name is not unique"));
xen_vm_set_free(vms);
return -1;
}
@@ -1476,7 +1504,8 @@ xenapiDomainDefineXML (virConnectPtr conn, const char *xml)
if (!session->ok)
xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
else
- xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Couldn't get VM information from XML");
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
+ _("Couldn't get VM information from XML"));
virDomainDefFree(defPtr);
return NULL;
}
@@ -1508,7 +1537,8 @@ xenapiDomainUndefine (virDomainPtr dom)
xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
if (vms->size != 1) {
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Domain name is not unique");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ _("Domain name is not unique"));
xen_vm_set_free(vms);
return -1;
}
@@ -1522,7 +1552,7 @@ xenapiDomainUndefine (virDomainPtr dom)
return 0;
}
if (vms) xen_vm_set_free(vms);
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, "");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
return -1;
}
@@ -1543,7 +1573,8 @@ xenapiDomainGetAutostart (virDomainPtr dom, int *autostart)
xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
if (vms->size != 1) {
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Domain name is not unique");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ _("Domain name is not unique"));
xen_vm_set_free(vms);
return -1;
}
@@ -1569,7 +1600,7 @@ xenapiDomainGetAutostart (virDomainPtr dom, int *autostart)
return 0;
}
if (vms) xen_vm_set_free(vms);
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, "");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
return -1;
}
@@ -1588,7 +1619,8 @@ xenapiDomainSetAutostart (virDomainPtr dom, int autostart)
xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
if (vms->size != 1) {
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Domain name is not unique");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ _("Domain name is not unique"));
xen_vm_set_free(vms);
return -1;
}
@@ -1607,7 +1639,7 @@ xenapiDomainSetAutostart (virDomainPtr dom, int autostart)
return 0;
}
if (vms) xen_vm_set_free(vms);
- xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, "");
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
return -1;
}
@@ -1636,12 +1668,14 @@ xenapiNodeGetFreeMemory (virConnectPtr conn)
xen_host_metrics_get_all(session, &xen_met_set);
if (xen_met_set != NULL) {
if (!xen_host_metrics_get_memory_free(session, (int64_t *)&freeMem, xen_met_set->contents[0])) {
- xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Couldn't get host metrics - memory information");
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
+ _("Couldn't get host metrics - memory information"));
freeMem = 0;
}
xen_host_metrics_set_free(xen_met_set);
} else {
- xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Couldn't get host metrics");
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
+ _("Couldn't get host metrics"));
}
return freeMem;
}
@@ -1657,7 +1691,7 @@ xenapiNodeGetCellsFreeMemory (virConnectPtr conn, unsigned long long *freeMems,
int startCell, int maxCells)
{
if (maxCells > 1 && startCell > 0) {
- xenapiSessionErrorHandler(conn, VIR_ERR_NO_SUPPORT, "");
+ xenapiSessionErrorHandler(conn, VIR_ERR_NO_SUPPORT, NULL);
return -1;
} else {
freeMems[0] = xenapiNodeGetFreeMemory(conn);
diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c
index 697ad39..60e3c8d 100644
--- a/src/xenapi/xenapi_utils.c
+++ b/src/xenapi/xenapi_utils.c
@@ -119,7 +119,7 @@ xenapiUtil_ParseQuery(virConnectPtr conn, xmlURIPtr uri, int *noVerify)
if (virStrToLong_i(queryParam->value, NULL, 10, noVerify) < 0 ||
(*noVerify != 0 && *noVerify != 1)) {
xenapiSessionErrorHandler(conn, VIR_ERR_INVALID_ARG,
- "Query parameter 'no_verify' has unexpected value (should be 0 or 1)");
+ _("Query parameter 'no_verify' has unexpected value (should be 0 or 1)"));
goto failure;
}
}
--
1.7.0.3.513.gc8ed0
2
1
[libvirt] [PATCH v2] Blank out invalid interface names with escaped letters etc.
by Stefan Berger 31 Mar '10
by Stefan Berger 31 Mar '10
31 Mar '10
Check that interface names only contain valid characters. Blank them out
otherwise.
Valid characters in this code are currently a-z,A-Z,0-9, '-' and '_'.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
---
src/conf/domain_conf.c | 9 ++++++++-
src/conf/domain_conf.h | 3 +++
2 files changed, 11 insertions(+), 1 deletion(-)
Index: libvirt-acl/src/conf/domain_conf.c
===================================================================
--- libvirt-acl.orig/src/conf/domain_conf.c
+++ libvirt-acl/src/conf/domain_conf.c
@@ -1776,6 +1776,11 @@ cleanup:
}
+static bool
+isValidIfname(const char *ifname) {
+ return strspn(ifname, VALID_IFNAME_CHARS) == strlen(ifname);
+}
+
/* Parse the XML definition for a network interface
* @param node XML nodeset to parse for net definition
@@ -1859,8 +1864,10 @@ virDomainNetDefParseXML(virCapsPtr caps,
xmlStrEqual(cur->name, BAD_CAST "target")) {
ifname = virXMLPropString(cur, "dev");
if ((ifname != NULL) &&
- (STRPREFIX((const char*)ifname, "vnet"))) {
+ ((STRPREFIX((const char*)ifname, "vnet")) ||
+ (!isValidIfname(ifname)))) {
/* An auto-generated target name, blank it out */
+ /* blank out invalid interface names */
VIR_FREE(ifname);
}
} else if ((script == NULL) &&
Index: libvirt-acl/src/conf/domain_conf.h
===================================================================
--- libvirt-acl.orig/src/conf/domain_conf.h
+++ libvirt-acl/src/conf/domain_conf.h
@@ -297,6 +297,9 @@ struct _virDomainNetDef {
virNWFilterHashTablePtr filterparams;
};
+#define VALID_IFNAME_CHARS \
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
+
enum virDomainChrTargetType {
VIR_DOMAIN_CHR_TARGET_TYPE_NULL = 0,
VIR_DOMAIN_CHR_TARGET_TYPE_MONITOR,
1
0
[libvirt] [PATCH] Keep track of guest paused state after disk IO / watchdog events
by Daniel P. Berrange 31 Mar '10
by Daniel P. Berrange 31 Mar '10
31 Mar '10
When a watchdog/IO error occurs, one of the possible actions that
QEMU might take is to pause the guest. In this scenario libvirt
needs to update its internal state for the VM, and emit a
lifecycle event:
VIR_DOMAIN_EVENT_SUSPENDED
with a detail being one of:
VIR_DOMAIN_EVENT_SUSPENDED_IOERROR
VIR_DOMAIN_EVENT_SUSPENDED_WATCHDOG
To future proof against possible QEMU support for multiple monitor
consoles, this patch also hooks into the 'STOPPED' event in QEMU
and emits a generic VIR_DOMAIN_EVENT_SUSPENDED_PAUSED event
* include/libvirt/libvirt.h.in: Add VIR_DOMAIN_EVENT_SUSPENDED_IOERROR
* src/qemu/qemu_driver.c: Update VM state to paused when IO error
or watchdog events occurrs
* src/qemu/qemu_monitor_json.c: Fix typo in disk IO event name
---
include/libvirt/libvirt.h.in | 2 +
src/qemu/qemu_driver.c | 83 ++++++++++++++++++++++++++++++++++++++----
src/qemu/qemu_monitor_json.c | 2 +-
3 files changed, 78 insertions(+), 9 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 6d8552f..7cb483e 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1384,6 +1384,8 @@ typedef enum {
typedef enum {
VIR_DOMAIN_EVENT_SUSPENDED_PAUSED = 0, /* Normal suspend due to admin pause */
VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED = 1, /* Suspended for offline migration */
+ VIR_DOMAIN_EVENT_SUSPENDED_IOERROR = 2, /* Suspended due to a disk I/O error */
+ VIR_DOMAIN_EVENT_SUSPENDED_WATCHDOG = 3, /* Suspended due to a watchdog firing */
} virDomainEventSuspendedDetailType;
/**
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9ee5da7..4291bc7 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -909,6 +909,38 @@ qemuHandleDomainReset(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
static int
+qemuHandleDomainStop(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
+ virDomainObjPtr vm)
+{
+ struct qemud_driver *driver = qemu_driver;
+ virDomainEventPtr event = NULL;
+
+ virDomainObjLock(vm);
+ if (vm->state == VIR_DOMAIN_RUNNING) {
+ VIR_DEBUG("Transitioned guest %s to paused state due to unknown event", vm->def->name);
+
+ vm->state = VIR_DOMAIN_PAUSED;
+ event = virDomainEventNewFromObj(vm,
+ VIR_DOMAIN_EVENT_SUSPENDED,
+ VIR_DOMAIN_EVENT_SUSPENDED_PAUSED);
+
+ if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
+ VIR_WARN("Unable to save status on vm %s after IO error", vm->def->name);
+ }
+ virDomainObjUnlock(vm);
+
+ if (event) {
+ qemuDriverLock(driver);
+ if (event)
+ qemuDomainEventQueue(driver, event);
+ qemuDriverUnlock(driver);
+ }
+
+ return 0;
+}
+
+
+static int
qemuHandleDomainRTCChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virDomainObjPtr vm,
long long offset)
@@ -943,15 +975,32 @@ qemuHandleDomainWatchdog(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
int action)
{
struct qemud_driver *driver = qemu_driver;
- virDomainEventPtr event;
+ virDomainEventPtr watchdogEvent = NULL;
+ virDomainEventPtr lifecycleEvent = NULL;
virDomainObjLock(vm);
- event = virDomainEventWatchdogNewFromObj(vm, action);
+ watchdogEvent = virDomainEventWatchdogNewFromObj(vm, action);
+
+ if (action == VIR_DOMAIN_EVENT_WATCHDOG_PAUSE &&
+ vm->state == VIR_DOMAIN_RUNNING) {
+ VIR_DEBUG("Transitioned guest %s to paused state due to watchdog", vm->def->name);
+
+ vm->state = VIR_DOMAIN_PAUSED;
+ lifecycleEvent = virDomainEventNewFromObj(vm,
+ VIR_DOMAIN_EVENT_SUSPENDED,
+ VIR_DOMAIN_EVENT_SUSPENDED_WATCHDOG);
+
+ if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
+ VIR_WARN("Unable to save status on vm %s after IO error", vm->def->name);
+ }
virDomainObjUnlock(vm);
- if (event) {
+ if (watchdogEvent || lifecycleEvent) {
qemuDriverLock(driver);
- qemuDomainEventQueue(driver, event);
+ if (watchdogEvent)
+ qemuDomainEventQueue(driver, watchdogEvent);
+ if (lifecycleEvent)
+ qemuDomainEventQueue(driver, lifecycleEvent);
qemuDriverUnlock(driver);
}
@@ -966,7 +1015,8 @@ qemuHandleDomainIOError(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
int action)
{
struct qemud_driver *driver = qemu_driver;
- virDomainEventPtr event;
+ virDomainEventPtr ioErrorEvent = NULL;
+ virDomainEventPtr lifecycleEvent = NULL;
const char *srcPath;
const char *devAlias;
virDomainDiskDefPtr disk;
@@ -982,12 +1032,28 @@ qemuHandleDomainIOError(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
devAlias = "";
}
- event = virDomainEventIOErrorNewFromObj(vm, srcPath, devAlias, action);
+ ioErrorEvent = virDomainEventIOErrorNewFromObj(vm, srcPath, devAlias, action);
+
+ if (action == VIR_DOMAIN_EVENT_IO_ERROR_PAUSE &&
+ vm->state == VIR_DOMAIN_RUNNING) {
+ VIR_DEBUG("Transitioned guest %s to paused state due to IO error", vm->def->name);
+
+ vm->state = VIR_DOMAIN_PAUSED;
+ lifecycleEvent = virDomainEventNewFromObj(vm,
+ VIR_DOMAIN_EVENT_SUSPENDED,
+ VIR_DOMAIN_EVENT_SUSPENDED_IOERROR);
+
+ if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
+ VIR_WARN("Unable to save status on vm %s after IO error", vm->def->name);
+ }
virDomainObjUnlock(vm);
- if (event) {
+ if (ioErrorEvent || lifecycleEvent) {
qemuDriverLock(driver);
- qemuDomainEventQueue(driver, event);
+ if (ioErrorEvent)
+ qemuDomainEventQueue(driver, ioErrorEvent);
+ if (lifecycleEvent)
+ qemuDomainEventQueue(driver, lifecycleEvent);
qemuDriverUnlock(driver);
}
@@ -1090,6 +1156,7 @@ no_memory:
static qemuMonitorCallbacks monitorCallbacks = {
.eofNotify = qemuHandleMonitorEOF,
.diskSecretLookup = findVolumeQcowPassphrase,
+ .domainStop = qemuHandleDomainStop,
.domainReset = qemuHandleDomainReset,
.domainRTCChange = qemuHandleDomainRTCChange,
.domainWatchdog = qemuHandleDomainWatchdog,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 3901d46..eac3aca 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -66,7 +66,7 @@ struct {
{ "STOP", qemuMonitorJSONHandleStop, },
{ "RTC_CHANGE", qemuMonitorJSONHandleRTCChange, },
{ "WATCHDOG", qemuMonitorJSONHandleWatchdog, },
- { "DISK_IO_ERROR", qemuMonitorJSONHandleIOError, },
+ { "BLOCK_IO_ERROR", qemuMonitorJSONHandleIOError, },
{ "VNC_CONNECTED", qemuMonitorJSONHandleVNCConnect, },
{ "VNC_INITIALIZED", qemuMonitorJSONHandleVNCInitialize, },
{ "VNC_DISCONNECTED", qemuMonitorJSONHandleVNCDisconnect, },
--
1.6.2.5
2
2
Adds $(AM_V_GEN) to many more manual makefile.am rules that
were generating files
---
daemon/Makefile.am | 28 ++++++++++++++--------------
src/Makefile.am | 18 +++++++++---------
tools/Makefile.am | 40 ++++++++++++++++++++--------------------
3 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index e117b97..a82e9a9 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -172,16 +172,16 @@ remote.c: remote_dispatch_prototypes.h \
REMOTE_PROTOCOL = $(top_srcdir)/src/remote/remote_protocol.x
remote_dispatch_prototypes.h: $(srcdir)/remote_generate_stubs.pl $(REMOTE_PROTOCOL)
- perl -w $(srcdir)/remote_generate_stubs.pl -p $(REMOTE_PROTOCOL) > $@
+ $(AM_V_GEN)perl -w $(srcdir)/remote_generate_stubs.pl -p $(REMOTE_PROTOCOL) > $@
remote_dispatch_table.h: $(srcdir)/remote_generate_stubs.pl $(REMOTE_PROTOCOL)
- perl -w $(srcdir)/remote_generate_stubs.pl -t $(REMOTE_PROTOCOL) > $@
+ $(AM_V_GEN)perl -w $(srcdir)/remote_generate_stubs.pl -t $(REMOTE_PROTOCOL) > $@
remote_dispatch_args.h: $(srcdir)/remote_generate_stubs.pl $(REMOTE_PROTOCOL)
- perl -w $(srcdir)/remote_generate_stubs.pl -a $(REMOTE_PROTOCOL) > $@
+ $(AM_V_GEN)perl -w $(srcdir)/remote_generate_stubs.pl -a $(REMOTE_PROTOCOL) > $@
remote_dispatch_ret.h: $(srcdir)/remote_generate_stubs.pl $(REMOTE_PROTOCOL)
- perl -w $(srcdir)/remote_generate_stubs.pl -r $(REMOTE_PROTOCOL) > $@
+ $(AM_V_GEN)perl -w $(srcdir)/remote_generate_stubs.pl -r $(REMOTE_PROTOCOL) > $@
LOGROTATE_CONFS = libvirtd.qemu.logrotate libvirtd.lxc.logrotate \
libvirtd.uml.logrotate
@@ -195,16 +195,16 @@ libvirtd.qemu.logrotate: libvirtd.qemu.logrotate.in
mv $@-t $@
libvirtd.lxc.logrotate: libvirtd.lxc.logrotate.in
- sed \
+ $(AM_V_GEN)sed \
-e 's![@]localstatedir[@]!$(localstatedir)!g' \
- < $< > $@-t
- mv $@-t $@
+ < $< > $@-t && \
+ mv $@-t $@
libvirtd.uml.logrotate: libvirtd.uml.logrotate.in
- sed \
+ $(AM_V_GEN)sed \
-e 's![@]localstatedir[@]!$(localstatedir)!g' \
- < $< > $@-t
- mv $@-t $@
+ < $< > $@-t && \
+ mv $@-t $@
install-logrotate: $(LOGROTATE_CONFS)
mkdir -p $(DESTDIR)$(localstatedir)/log/libvirt/qemu/
@@ -231,13 +231,13 @@ uninstall-init:
BUILT_SOURCES += libvirtd.init
libvirtd.init: libvirtd.init.in
- sed \
+ $(AM_V_GEN)sed \
-e s!\@localstatedir\@!@localstatedir@!g \
-e s!\@sbindir\@!@sbindir@!g \
-e s!\@sysconfdir\@!@sysconfdir@!g \
- < $< > $@-t
- chmod a+x $@-t
- mv $@-t $@
+ < $< > $@-t && \
+ chmod a+x $@-t && \
+ mv $@-t $@
check-local:
test -x '$(AUGPARSE)' \
diff --git a/src/Makefile.am b/src/Makefile.am
index c661a5c..cc0a7d6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -870,17 +870,17 @@ EXTRA_DIST += \
BUILT_SOURCES = libvirt.syms
libvirt.syms: libvirt_public.syms $(USED_SYM_FILES)
- rm -f $@-tmp $@
- printf '# WARNING: generated from the following:\n# $^\n\n' >$@-tmp
- cat $(srcdir)/libvirt_public.syms >>$@-tmp
- printf '\n\n# Private symbols\n\n' >>$@-tmp
- printf 'LIBVIRT_PRIVATE_$(VERSION) {\n\n' >>$@-tmp
- printf 'global:\n\n' >>$@-tmp
+ $(AM_V_GEN)rm -f $@-tmp $@ ; \
+ printf '# WARNING: generated from the following:\n# $^\n\n' >$@-tmp && \
+ cat $(srcdir)/libvirt_public.syms >>$@-tmp && \
+ printf '\n\n# Private symbols\n\n' >>$@-tmp && \
+ printf 'LIBVIRT_PRIVATE_$(VERSION) {\n\n' >>$@-tmp && \
+ printf 'global:\n\n' >>$@-tmp && \
for file in $(USED_SYM_FILES); do \
cat $(srcdir)/$$file >>$@-tmp; \
- done
- printf '\n\nlocal:\n*;\n\n};' >>$@-tmp
- chmod a-w $@-tmp
+ done && \
+ printf '\n\nlocal:\n*;\n\n};' >>$@-tmp && \
+ chmod a-w $@-tmp && \
mv $@-tmp libvirt.syms
# Empty source list - it merely links a bunch of convenience libs together
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 46107f6..33a3216 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -17,18 +17,18 @@ man1_MANS = virt-xml-validate.1 virt-pki-validate.1 virsh.1
virt-xml-validate: virt-xml-validate.in Makefile
- sed -e 's,@SCHEMADIR@,$(pkgdatadir)/schemas,' < $< > $@ || (rm $@ && exit 1)
- chmod +x $@
+ $(AM_V_GEN)sed -e 's,@SCHEMADIR@,$(pkgdatadir)/schemas,' < $< > $@ \
+ || (rm $@ && exit 1) && chmod +x $@
virt-xml-validate.1: virt-xml-validate
- $(POD2MAN) $< $@
+ $(AM_V_GEN)$(POD2MAN) $< $@
virt-pki-validate: virt-pki-validate.in Makefile
- sed -e 's,@SYSCONFDIR@,$(sysconfdir),' < $< > $@ || (rm $@ && exit 1)
- chmod +x $@
+ $(AM_V_GEN)sed -e 's,@SYSCONFDIR@,$(sysconfdir),' < $< > $@ \
+ || (rm $@ && exit 1) && chmod +x $@
virt-pki-validate.1: virt-pki-validate
- $(POD2MAN) $< $@
+ $(AM_V_GEN)$(POD2MAN) $< $@
virsh_SOURCES = \
console.c console.h \
@@ -55,24 +55,24 @@ virsh_CFLAGS = \
BUILT_SOURCES = virsh-net-edit.c virsh-pool-edit.c
virsh-net-edit.c: virsh.c Makefile.am
- rm -f $@-tmp
- echo '/* Automatically generated from: $^ */' > $@-tmp
- echo 'static int' >> $@-tmp
+ $(AM_V_GEN)rm -f $@-tmp && \
+ echo '/* Automatically generated from: $^ */' > $@-tmp && \
+ echo 'static int' >> $@-tmp && \
awk '/^cmdEdit/, /^}/' $< \
| sed -e 's/domain/network/g' \
-e 's/Domain/Network/g' \
-e 's/cmdEdit/cmdNetworkEdit/g' \
-e 's/dom/network/g' \
-e 's/int flags.*/int flags = 0;/g' \
- >> $@-tmp
- chmod a-w $@-tmp
- rm -f $@
+ >> $@-tmp && \
+ chmod a-w $@-tmp && \
+ rm -f $@ && \
mv $@-tmp $@
virsh-pool-edit.c: virsh.c Makefile.am
- rm -f $@-tmp
- echo '/* Automatically generated from: $^ */' > $@-tmp
- echo 'static int' >> $@-tmp
+ $(AM_V_GEN)rm -f $@-tmp && \
+ echo '/* Automatically generated from: $^ */' > $@-tmp && \
+ echo 'static int' >> $@-tmp && \
awk '/^cmdEdit/, /^}/' $< \
| sed -e 's/domain/pool/g' \
-e 's/vshCommandOptDomain/vshCommandOptPool/g' \
@@ -83,9 +83,9 @@ virsh-pool-edit.c: virsh.c Makefile.am
-e 's/\(virStoragePoolDefineXML.*\));/\1, 0);/' \
-e 's/dom/pool/g' \
-e 's/int flags.*/int flags = 0;/g' \
- >> $@-tmp
- chmod a-w $@-tmp
- rm -f $@
+ >> $@-tmp && \
+ chmod a-w $@-tmp && \
+ rm -f $@ && \
mv $@-tmp $@
@@ -110,13 +110,13 @@ virsh_LDADD += virsh_win_icon.$(OBJEXT)
# information is needed in this area.
virsh_win_icon.$(OBJEXT): virsh_win_icon.rc
- $(WINDRES) \
+ $(AM_V_GEN)$(WINDRES) \
--input-format rc --input $< \
--output-format coff --output $@
endif
virsh.1: virsh.pod
- $(POD2MAN) $< $@
+ $(AM_V_GEN)$(POD2MAN) $< $@
CLEANFILES = $(bin_SCRIPTS) $(man1_MANS)
--
1.6.2.5
2
1
Hi,
I have KVM qemu installed on Fedora 12 host server.
My VMs are marked to autostart. When I reboot my host server the
virtual machines starts but halts on its bios display screen.
If I login mannually destroy the VMs and start again, it just works
without any errors.
Can someone please help me with this issue ?
error logs I found are this :
Starting libvirtd daemon: [ OK ]
error: unable to connect to '/var/run/libvirt/libvirt-sock': No such
file or directory
error: failed to connect to the hypervisor
some more info :
virsh capabilities
<capabilities>
<host>
<cpu>
<arch>i686</arch>
</cpu>
<migration_features>
<live/>
<uri_transports>
<uri_transport>tcp</uri_transport>
</uri_transports>
</migration_features>
</host>
<guest>
<os_type>hvm</os_type>
<arch name='i686'>
<wordsize>32</wordsize>
<emulator>/usr/bin/qemu</emulator>
<machine>pc-0.11</machine>
<machine canonical='pc-0.11'>pc</machine>
<machine>pc-0.10</machine>
<machine>isapc</machine>
<domain type='qemu'>
</domain>
<domain type='kvm'>
<emulator>/usr/bin/qemu-kvm</emulator>
<machine>pc-0.11</machine>
<machine canonical='pc-0.11'>pc</machine>
<machine>pc-0.10</machine>
<machine>isapc</machine>
</domain>
</arch>
<features>
<pae/>
<nonpae/>
<acpi default='on' toggle='yes'/>
<apic default='on' toggle='no'/>
</features>
</guest>
<guest>
<os_type>hvm</os_type>
<arch name='x86_64'>
<wordsize>64</wordsize>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<machine>pc-0.11</machine>
<machine canonical='pc-0.11'>pc</machine>
<machine>pc-0.10</machine>
<machine>isapc</machine>
<domain type='qemu'>
</domain>
</arch>
<features>
<acpi default='on' toggle='yes'/>
<apic default='on' toggle='no'/>
</features>
</guest>
</capabilities>
Kindly let me know if any more information required inorder to fix this issue.
--
Regards,
Ameya Pandit
Buzz: 90040 27390 | www.ameyapandit.com
1
0
31 Mar '10
---
src/.gitignore | 1 +
tests/.gitignore | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/.gitignore b/src/.gitignore
index 26b8689..e407dcb 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -15,3 +15,4 @@ libvirt_lxc
libvirt.syms
*.i
*.s
+virt-aa-helper
diff --git a/tests/.gitignore b/tests/.gitignore
index 399baee..387a924 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -33,3 +33,4 @@ object-locking-files.txt
esxutilstest
vmx2xmltest
xml2vmxtest
+secaatest
--
1.6.3.3
1
0
Hi all,
I am using libvirt for managing KVM. I would also like to manage Vserver using libvirt.
Is there any patch available for vserver ? When will libvirt release official patch for vserver?
Thanks,
Chaitra
Regards,
Chaitra GN
"I don't think anything is unrealistic if you believe you can do it"
________________________________
This Email may contain confidential or privileged information for the intended recipient (s) If you are not the intended recipient, please do not use or disseminate the information, notify the sender and delete it from your system.
______________________________________________________________________
2
1
Hi all,
I am using libvirt for managing KVM. I would also like to manage Vserver also using libvirt.
Is there any patch available for vserver ? When will libvirt relase official patch for vserver?
Thanks,
Chaitra
________________________________
This Email may contain confidential or privileged information for the intended recipient (s) If you are not the intended recipient, please do not use or disseminate the information, notify the sender and delete it from your system.
______________________________________________________________________
2
2
31 Mar '10
Here is a couple of patches related to make dist, then build from
resulting tarball and rpm building.
The first one adds a few missing header files in the associated file
variables, it's needed otherwise the missing headers would break
compilation from a distribution tarball
The second one handles the xml filter files, first they need to be
added to EXTRA_DIST from their Makefile.am otherwise they are missing
from the tarball, and second that set of file in /etc/ need to be
listed in the rpm spec file, associated with the main libvirt rpm
(i.e. where the daemon resides as it's useless with just the client).
I think those are fairly uncontroversial and are needed to not
break the distribution, but I will probably commit those tomorrow,
in case someone points out something stupid :-)
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/
1
1
[libvirt] [PATCH] nwfilter: Make entries in a int-2-string map more readable
by Stefan Berger 30 Mar '10
by Stefan Berger 30 Mar '10
30 Mar '10
A cosmetic change that makes the entries in the int-2-string maps look
more readable. Add some missing entries.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
---
src/conf/nwfilter_conf.c | 97 +++++++++++++----------------------------------
1 file changed, 28 insertions(+), 69 deletions(-)
Index: libvirt-acl/src/conf/nwfilter_conf.c
===================================================================
--- libvirt-acl.orig/src/conf/nwfilter_conf.c
+++ libvirt-acl/src/conf/nwfilter_conf.c
@@ -105,6 +105,9 @@ struct int_map {
const char *val;
};
+#define INTMAP_ENTRY(ATT, VAL) { .attr = ATT, .val = VAL }
+#define INTMAP_ENTRY_LAST { .val = NULL }
+
/*
* only one filter update allowed
@@ -388,18 +391,10 @@ struct _virXMLAttr2Struct
static const struct int_map macProtoMap[] = {
- {
- .attr = ETHERTYPE_ARP,
- .val = "arp",
- }, {
- .attr = ETHERTYPE_IP,
- .val = "ipv4",
- }, {
- .attr = ETHERTYPE_IPV6,
- .val = "ipv6",
- }, {
- .val = NULL,
- }
+ INTMAP_ENTRY(ETHERTYPE_ARP , "arp"),
+ INTMAP_ENTRY(ETHERTYPE_IP , "ipv4"),
+ INTMAP_ENTRY(ETHERTYPE_IPV6, "ipv6"),
+ INTMAP_ENTRY_LAST
};
@@ -486,36 +481,16 @@ checkMACMask(enum attrDatatype datatype
* supported arp opcode -- see 'ebtables -h arp' for the naming
*/
static const struct int_map arpOpcodeMap[] = {
- {
- .attr = 1,
- .val = "Request",
- } , {
- .attr = 2,
- .val = "Reply",
- } , {
- .attr = 3,
- .val = "Request_Reverse",
- } , {
- .attr = 4,
- .val = "Reply_Reverse",
- } , {
- .attr = 5,
- .val = "DRARP_Request",
- } , {
- .attr = 6,
- .val = "DRARP_Reply",
- } , {
- .attr = 7,
- .val = "DRARP_Error",
- } , {
- .attr = 8,
- .val = "InARP_Request",
- } , {
- .attr = 9,
- .val = "ARP_NAK",
- } , {
- .val = NULL,
- }
+ INTMAP_ENTRY(1, "Request"),
+ INTMAP_ENTRY(2, "Reply"),
+ INTMAP_ENTRY(3, "Request_Reverse"),
+ INTMAP_ENTRY(4, "Reply_Reverse"),
+ INTMAP_ENTRY(5, "DRARP_Request"),
+ INTMAP_ENTRY(6, "DRARP_Reply"),
+ INTMAP_ENTRY(7, "DRARP_Error"),
+ INTMAP_ENTRY(8, "InARP_Request"),
+ INTMAP_ENTRY(9, "ARP_NAK"),
+ INTMAP_ENTRY_LAST
};
@@ -562,37 +537,21 @@ arpOpcodeFormatter(virBufferPtr buf,
static const struct int_map ipProtoMap[] = {
- {
- .attr = IPPROTO_TCP,
- .val = "tcp",
- } , {
- .attr = IPPROTO_UDP,
- .val = "udp",
+ INTMAP_ENTRY(IPPROTO_TCP, "tcp"),
+ INTMAP_ENTRY(IPPROTO_UDP, "udp"),
#ifdef IPPROTO_UDPLITE
- } , {
- .attr = IPPROTO_UDPLITE,
- .val = "udplite",
+ INTMAP_ENTRY(IPPROTO_UDPLITE, "udplite"),
#endif
- } , {
- .attr = IPPROTO_ESP,
- .val = "esp",
- } , {
- .attr = IPPROTO_AH,
- .val = "ah",
- } , {
- .attr = IPPROTO_ICMP,
- .val = "icmp",
- } , {
- .attr = IPPROTO_IGMP,
- .val = "igmp",
+ INTMAP_ENTRY(IPPROTO_ESP, "esp"),
+ INTMAP_ENTRY(IPPROTO_AH, "ah"),
+ INTMAP_ENTRY(IPPROTO_ICMP, "icmp"),
+ INTMAP_ENTRY(IPPROTO_IGMP, "igmp"),
#ifdef IPPROTO_SCTP
- } , {
- .attr = IPPROTO_SCTP,
- .val = "sctp",
+ INTMAP_ENTRY(IPPROTO_SCTP, "sctp"),
#endif
- } , {
- .val = NULL,
- }
+ INTMAP_ENTRY(IPPROTO_IPV6, "ipv6"),
+ INTMAP_ENTRY(IPPROTO_ICMPV6, "icmpv6"),
+ INTMAP_ENTRY_LAST
};
4
6
[libvirt] CfP with Extended Deadline 5th Workshop on Virtualization in High-Performance Cloud Computing (VHPC'10)
by Michael Alexander 30 Mar '10
by Michael Alexander 30 Mar '10
30 Mar '10
Apologies if you received multiple copies of this message.
=================================================================
CALL FOR PAPERS
5th Workshop on
Virtualization in High-Performance Cloud Computing
VHPC'10
as part of Euro-Par 2010, Island of Ischia-Naples, Italy
=================================================================
Date: August 31, 2010
Euro-Par 2009: http://www.europar2010.org/
Workshop URL: http://vhpc.org
SUBMISSION DEADLINE:
Abstracts: April 4, 2010 (extended)
Full Paper: June 19, 2010 (extended)
Scope:
Virtualization has become a common abstraction layer in modern data
centers, enabling resource owners to manage complex infrastructure
independently of their applications. Conjointly virtualization is
becoming a driving technology for a manifold of industry grade IT
services. Piloted by the Amazon Elastic Computing Cloud services, the
cloud concept includes the notion of a separation between resource
owners and users, adding services such as hosted application
frameworks and queuing. Utilizing the same infrastructure, clouds
carry significant potential for use in high-performance scientific
computing. The ability of clouds to provide for requests and releases
of vast computing resource dynamically and close to the marginal cost
of providing the services is unprecedented in the history of
scientific and commercial computing.
Distributed computing concepts that leverage federated resource access
are popular within the grid community, but have not seen previously
desired deployed levels so far. Also, many of the scientific
datacenters have not adopted virtualization or cloud concepts yet.
This workshop aims to bring together industrial providers with the
scientific community in order to foster discussion, collaboration and
mutual exchange of knowledge and experience.
The workshop will be one day in length, composed of 20 min paper
presentations, each followed by 10 min discussion sections.
Presentations may be accompanied by interactive demonstrations. It
concludes with a 30 min panel discussion by presenters.
TOPICS
Topics include, but are not limited to, the following subjects:
- Virtualization in cloud, cluster and grid HPC environments
- VM cloud, cluster load distribution algorithms
- Cloud, cluster and grid filesystems
- QoS and and service level guarantees
- Cloud programming models, APIs and databases
- Software as a service (SaaS)
- Cloud provisioning
- Virtualized I/O
- VMMs and storage virtualization
- MPI, PVM on virtual machines
- High-performance network virtualization
- High-speed interconnects
- Hypervisor extensions
- Tools for cluster and grid computing
- Xen/other VMM cloud/cluster/grid tools
- Raw device access from VMs
- Cloud reliability, fault-tolerance, and security
- Cloud load balancing
- VMs - power efficiency
- Network architectures for VM-based environments
- VMMs/Hypervisors
- Hardware support for virtualization
- Fault tolerant VM environments
- Workload characterizations for VM-based environments
- Bottleneck management
- Metering
- VM-based cloud performance modeling
- Cloud security, access control and data integrity
- Performance management and tuning hosts and guest VMs
- VMM performance tuning on various load types
- Research and education use cases
- Cloud use cases
- Management of VM environments and clouds
- Deployment of VM-based environments
PAPER SUBMISSION
Papers submitted to the workshop will be reviewed by at least two
members of the program committee and external reviewers. Submissions
should include abstract, key words, the e-mail address of the
corresponding author, and must not exceed 10 pages, including tables
and figures at a main font size no smaller than 11 point. Submission
of a paper should be regarded as a commitment that, should the paper
be accepted, at least one of the authors will register and attend the
conference to present the work.
Accepted papers will be published in the Springer LNCS series - the
format must be according to the Springer LNCS Style. Initial
submissions are in PDF, accepted papers will be requested to provided
source files.
Format Guidelines: http://www.springer.de/comp/lncs/authors.html
Submission Link: http://edas.info/newPaper.php?c=8553
IMPORTANT DATES
April 4 - Abstract submission due (extended)
May 19 - Full paper submission (extended)
July 14 - Acceptance notification
August 3 - Camera-ready version due
August 31 - September 3 - conference
CHAIR
Michael Alexander (chair), scaledinfra technologies GmbH, Austria
Gianluigi Zanetti (co-chair), CRS4, Italy
PROGRAM COMMITTEE
Padmashree Apparao, Intel Corp., USA
Volker Buege, University of Karlsruhe, Germany
Roberto Canonico, University of Napoli Federico II, Italy
Tommaso Cucinotta, Scuola Superiore Sant'Anna, Italy
Werner Fischer, Thomas Krenn AG, Germany
William Gardner, University of Guelph, Canada
Wolfgang Gentzsch, DEISA. Max Planck Gesellschaft, Germany
Derek Groen, UVA, The Netherlands
Marcus Hardt, Forschungszentrum Karlsruhe, Germany
Sverre Jarp, CERN, Switzerland
Shantenu Jha, Louisiana State University, USA
Xuxian Jiang, NC State, USA
Kenji Kaneda, Google, Japan
Yves Kemp, DESY Hamburg, Germany
Ignacio Llorente, Universidad Complutense de Madrid, Spain
Naoya Maruyama, Tokyo Institute of Technology, Japan
Jean-Marc Menaud, Ecole des Mines de Nantes, France
Anastassios Nano, National Technical University of Athens, Greece
Oliver Oberst, Karlsruhe Institute of Technology, Germany
Jose Renato Santos, HP Labs, USA
Borja Sotomayor, University of Chicago, USA
Yoshio Turner, HP Labs, USA
Kurt Tuschku, University of Vienna, Austria
Lizhe Wang, Indiana University, USA
Chao-Tung Yang, Tunghai University, Taiwan
DURATION: Workshop Duration is one day.
GENERAL INFORMATION
The workshop will be held as part of Euro-Par 2010,
Island of Ischia-Naples, Italy.
Euro-Par 2010: http://www.europar2010.org/
1
0
Hey Mattias,
I'm currently working on the semantics of
virDomainSnapshotDelete(), which has been renamed from
the earlier virDomainSnapshotDeactivate(). In qemu/kvm,
it seems like it is possible to delete a snapshot at any
time, even while that snapshot is running (though I'm not
yet sure exactly what happens in that case). Talking
to Jirka, it seems like the virtualbox GUI doesn't allow you to
do any operations at all on snapshots while a domain is running,
although we don't know yet if this is a restriction in the
API as well.
My questions for you are about how ESX handles this situation:
1) Can you manipulate a domain's snapshots while that domain is
running?
2) If so, can you delete the snapshot that is currently running?
If so, what happens?
--
Chris Lalancette
2
2
Picks up fixes for gethostname compilation problems on mingw.
* .gnulib: Update to latest.
* build-aux/.gitignore: Regenerate.
* cfg.mk (local-checks-to-skip): Avoid new test not relevent to
libvirt.
---
This replaces
https://www.redhat.com/archives/libvir-list/2010-March/msg00915.html,
and should fix the issues Matthias was seeing with compiling gnulib
on mingw.
.gnulib | 2 +-
build-aux/.gitignore | 1 +
cfg.mk | 1 +
3 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/.gnulib b/.gnulib
index 10d66ae..4f01268 160000
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit 10d66aedfdd610f731c8c54152b9dfca3efbee12
+Subproject commit 4f01268d0c584c20704e42527f4fa125e7525aae
diff --git a/build-aux/.gitignore b/build-aux/.gitignore
index 29b1e03..8717628 100644
--- a/build-aux/.gitignore
+++ b/build-aux/.gitignore
@@ -6,6 +6,7 @@
/useless-if-before-free
/vc-list-files
arg-nonnull.h
+c++defs.h
config.rpath
gitlog-to-changelog
mkinstalldirs
diff --git a/cfg.mk b/cfg.mk
index 27cfca4..0c41ae5 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -51,6 +51,7 @@ local-checks-to-skip = \
sc_space_tab \
sc_sun_os_names \
sc_system_h_headers \
+ sc_texinfo_acronym \
sc_tight_scope \
sc_two_space_separator_in_usage \
sc_error_message_uppercase \
--
1.6.6.1
2
6
* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Add
-fdiagnostics-show-option.
---
Here's an example of how things change, when using './configure
--enable-compiler-warnings=error' and introducing something gcc
would warn about:
CC libvirt_driver_nwfilter_la-nwfilter_ebiptables_driver.lo
cc1: warnings being treated as errors
nwfilter/nwfilter_ebiptables_driver.c: In function '_iptablesCreateRuleInstance':
nwfilter/nwfilter_ebiptables_driver.c:1059: error: unused variable 'oops' [-Wunused-variable]
acinclude.m4 | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/acinclude.m4 b/acinclude.m4
index f00933f..7fa2d67 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -13,13 +13,17 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
dnl ******************************
AC_ARG_ENABLE(compile-warnings,
- AC_HELP_STRING([--enable-compile-warnings=@<:@no/minimum/yes/maximum/error@:>@],
- [Turn on compiler warnings]),,
+ [AC_HELP_STRING([--enable-compile-warnings=@<:@no/minimum/yes/maximum/error@:>@],
+ [Turn on compiler warnings])],,
[enable_compile_warnings="m4_default([$1],[maximum])"])
warnCFLAGS=
- common_flags="-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fasynchronous-unwind-tables"
+ common_flags=
+ common_flags="$common_flags -Wp,-D_FORTIFY_SOURCE=2"
+ common_flags="$common_flags -fexceptions"
+ common_flags="$common_flags -fasynchronous-unwind-tables"
+ common_flags="$common_flags -fdiagnostics-show-option"
case "$enable_compile_warnings" in
no)
--
1.6.6.1
2
1
This patch adds a dummy nwfilter driver to the test driver so that the
int-overflow test passes without modifications.
Signed-off-by: Stefan Berger <Stefanb(a)us.ibm.com>
Index: libvirt/src/test/test_driver.c
===================================================================
--- libvirt.orig/src/test/test_driver.c
+++ libvirt/src/test/test_driver.c
@@ -5205,6 +5205,22 @@ static int testSecretClose(virConnectPtr
return 0;
}
+
+static virDrvOpenStatus testNWFilterOpen(virConnectPtr conn,
+ virConnectAuthPtr auth ATTRIBUTE_UNUSED,
+ int flags ATTRIBUTE_UNUSED) {
+ if (STRNEQ(conn->driver->name, "Test"))
+ return VIR_DRV_OPEN_DECLINED;
+
+ conn->secretPrivateData = conn->privateData;
+ return VIR_DRV_OPEN_SUCCESS;
+}
+
+static int testNWFilterClose(virConnectPtr conn) {
+ conn->nwfilterPrivateData = NULL;
+ return 0;
+}
+
static virDriver testDriver = {
VIR_DRV_TEST,
"Test",
@@ -5398,6 +5414,12 @@ static virSecretDriver testSecretDriver
};
+static virNWFilterDriver testNWFilterDriver = {
+ .name = "Test",
+ .open = testNWFilterOpen,
+ .close = testNWFilterClose,
+};
+
/**
* testRegister:
*
@@ -5418,6 +5440,8 @@ testRegister(void)
return -1;
if (virRegisterSecretDriver(&testSecretDriver) < 0)
return -1;
+ if (virRegisterNWFilterDriver(&testNWFilterDriver) < 0)
+ return -1;
return 0;
}
4
4
[libvirt] [PATCH] Use libvirt's existing ipv6/ipv4 parser/printer rather than self-written ones
by Stefan Berger 30 Mar '10
by Stefan Berger 30 Mar '10
30 Mar '10
This patch changes the network filtering code to use libvirt's existing
IPv4 and IPv6 address parsers/printers rather than my self-written ones.
I am introducing a new function in network.c that counts the number of
bits in a netmask and ensures that the given address is indeed a
netmask, return -1 on error or values of 0-32 for IPv4 addresses and
0-128 for IPv6 addresses. I then based the function checking for valid
netmask on invoking this function.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
---
src/conf/nwfilter_conf.c | 181 ++----------------------------
src/conf/nwfilter_conf.h | 8 -
src/nwfilter/nwfilter_ebiptables_driver.c | 46 ++++---
src/util/network.c | 173 +++++++++++++++-------------
src/util/network.h | 3
5 files changed, 142 insertions(+), 269 deletions(-)
Index: libvirt-acl/src/conf/nwfilter_conf.h
===================================================================
--- libvirt-acl.orig/src/conf/nwfilter_conf.h
+++ libvirt-acl/src/conf/nwfilter_conf.h
@@ -33,6 +33,8 @@
# include "util.h"
# include "hash.h"
# include "xml.h"
+# include "network.h"
+
/**
* Chain suffix size is:
@@ -85,11 +87,7 @@ struct _nwMACAddress {
typedef struct _nwIPAddress nwIPAddress;
typedef nwIPAddress *nwIPAddressPtr;
struct _nwIPAddress {
- int isIPv6;
- union {
- unsigned char ipv4Addr[4];
- unsigned char ipv6Addr[16];
- } addr;
+ virSocketAddr addr;
};
Index: libvirt-acl/src/util/network.c
===================================================================
--- libvirt-acl.orig/src/util/network.c
+++ libvirt-acl/src/util/network.c
@@ -219,88 +219,10 @@ virSocketGetPort(virSocketAddrPtr addr)
* Returns 0 in case of success and -1 in case of error
*/
int virSocketAddrIsNetmask(virSocketAddrPtr netmask) {
- int i;
-
- if (netmask == NULL)
- return(-1);
-
- if (netmask->stor.ss_family == AF_INET) {
- virIPv4Addr tm;
- unsigned char tmp;
- int ok = 0;
-
- if (getIPv4Addr(netmask, &tm) < 0)
- return(-1);
-
- for (i = 0;i < 4;i++) {
- if (tm[i] != 0)
- break;
- }
-
- if (i >= 4)
- return(0);
-
- tmp = 0xFF;
- do {
- if (tm[i] == tmp) {
- ok = 1;
- break;
- }
- tmp <<= 1;
- } while (tmp != 0);
- if (ok == 0)
- return(-1);
- i++;
-
- if (i >= 4)
- return(0);
-
- for (;i < 4;i++) {
- if (tm[i] != 0xFF)
- return(-1);
- }
- } else if (netmask->stor.ss_family == AF_INET6) {
- virIPv6Addr tm;
- unsigned short tmp;
- int ok = 0;
-
- /*
- * Hum, on IPv6 people use prefixes instead of netmask
- */
- if (getIPv6Addr(netmask, &tm) < 0)
- return(-1);
-
- for (i = 0;i < 8;i++) {
- if (tm[i] != 0)
- break;
- }
-
- if (i >= 8)
- return(0);
-
- tmp = 0xFFFF;
- do {
- if (tm[i] == tmp) {
- ok = 1;
- break;
- }
- tmp <<= 1;
- } while (tmp != 0);
- if (ok == 0)
- return(-1);
- i++;
-
- if (i >= 8)
- return(0);
-
- for (;i < 8;i++) {
- if (tm[i] != 0xFFFF)
- return(-1);
- }
- } else {
- return(-1);
- }
- return(0);
+ int n = virSocketGetNumNetmaskBits(netmask);
+ if (n < 0)
+ return -1;
+ return 0;
}
/**
@@ -415,3 +337,90 @@ int virSocketGetRange(virSocketAddrPtr s
}
return(ret);
}
+
+
+/**
+ * virGetNumNetmaskBits
+ * @netmask: the presumed netmask
+ *
+ * Get the number of netmask bits in a netmask.
+ *
+ * Returns the number of bits in the netmask or -1 if an error occurred
+ * or the netmask is invalid.
+ */
+int virSocketGetNumNetmaskBits(const virSocketAddrPtr netmask)
+{
+ int i, j;
+ int c = 0;
+
+ if (netmask->stor.ss_family == AF_INET) {
+ virIPv4Addr tm;
+ uint8_t bit;
+
+ if (getIPv4Addr(netmask, &tm) < 0)
+ return -1;
+
+ for (i = 0; i < 4; i++)
+ if (tm[i] == 0xff)
+ c += 8;
+ else
+ break;
+
+ if (c == 8 * 4)
+ return c;
+
+ j = i << 3;
+ while (j < (8 * 4)) {
+ bit = 1 << (7 - (j & 7));
+ if ((tm[j >> 3] & bit)) {
+ c++;
+ } else
+ break;
+ j++;
+ }
+
+ while (j < (8 * 4)) {
+ bit = 1 << (7 - (j & 7));
+ if ((tm[j >> 3] & bit))
+ return -1;
+ j++;
+ }
+
+ return c;
+ } else if (netmask->stor.ss_family == AF_INET6) {
+ virIPv6Addr tm;
+ uint16_t bit;
+
+ if (getIPv6Addr(netmask, &tm) < 0)
+ return -1;
+
+ for (i = 0; i < 8; i++)
+ if (tm[i] == 0xffff)
+ c += 16;
+ else
+ break;
+
+ if (c == 16 * 8)
+ return c;
+
+ j = i << 4;
+ while (j < (16 * 8)) {
+ bit = 1 << (15 - (j & 0xf));
+ if ((tm[j >> 4] & bit)) {
+ c++;
+ } else
+ break;
+ j++;
+ }
+
+ while (j < (16 * 8)) {
+ bit = 1 << (15 - (j & 0xf));
+ if ((tm[j >> 4]) & bit)
+ return -1;
+ j++;
+ }
+
+ return c;
+ }
+ return -1;
+}
Index: libvirt-acl/src/util/network.h
===================================================================
--- libvirt-acl.orig/src/util/network.h
+++ libvirt-acl/src/util/network.h
@@ -48,4 +48,7 @@ int virSocketAddrIsNetmask(virSocketAddr
int virSocketCheckNetmask (virSocketAddrPtr addr1,
virSocketAddrPtr addr2,
virSocketAddrPtr netmask);
+
+int virSocketGetNumNetmaskBits(const virSocketAddrPtr netmask);
+
#endif /* __VIR_NETWORK_H__ */
Index: libvirt-acl/src/conf/nwfilter_conf.c
===================================================================
--- libvirt-acl.orig/src/conf/nwfilter_conf.c
+++ libvirt-acl/src/conf/nwfilter_conf.c
@@ -473,22 +473,6 @@ checkValidMask(unsigned char *data, int
}
-/* check for a valid IPv4 mask */
-static bool
-checkIPv4Mask(enum attrDatatype datatype ATTRIBUTE_UNUSED, void *maskptr,
- virNWFilterRuleDefPtr nwf ATTRIBUTE_UNUSED)
-{
- return checkValidMask(maskptr, 4);
-}
-
-static bool
-checkIPv6Mask(enum attrDatatype datatype ATTRIBUTE_UNUSED, void *maskptr,
- virNWFilterRuleDefPtr nwf ATTRIBUTE_UNUSED)
-{
- return checkValidMask(maskptr, 16);
-}
-
-
static bool
checkMACMask(enum attrDatatype datatype ATTRIBUTE_UNUSED,
void *macMask,
@@ -498,16 +482,6 @@ checkMACMask(enum attrDatatype datatype
}
-static int getMaskNumBits(const unsigned char *mask, int len) {
- int i = 0;
- while (i < (len << 3)) {
- if (!(mask[i>>3] & (0x80 >> (i & 3))))
- break;
- i++;
- }
- return i;
-}
-
/*
* supported arp opcode -- see 'ebtables -h arp' for the naming
*/
@@ -1227,21 +1201,8 @@ static bool
virNWIPv4AddressParser(const char *input,
nwIPAddressPtr output)
{
- int i;
- char *endptr;
- const char *n = input;
- long int d;
-
- for (i = 0; i < 4; i++) {
- d = strtol(n, &endptr, 10);
- if (d < 0 || d > 255 ||
- (endptr - n > 3 ) ||
- (i <= 2 && *endptr != '.' ) ||
- (i == 3 && *endptr != '\0'))
- return 0;
- output->addr.ipv4Addr[i] = (unsigned char)d;
- n = endptr + 1;
- }
+ if (virSocketParseIpv4Addr(input, &output->addr) == -1)
+ return 0;
return 1;
}
@@ -1250,81 +1211,8 @@ static bool
virNWIPv6AddressParser(const char *input,
nwIPAddressPtr output)
{
- int i, j, pos;
- uint16_t n;
- int shiftpos = -1;
- char prevchar;
- char base;
-
- memset(output, 0x0, sizeof(*output));
-
- output->isIPv6 = 1;
-
- pos = 0;
- i = 0;
-
- while (i < 8) {
- j = 0;
- n = 0;
- while (1) {
- prevchar = input[pos++];
- if (prevchar == ':' || prevchar == 0) {
- if (j > 0) {
- output->addr.ipv6Addr[i * 2 + 0] = n >> 8;
- output->addr.ipv6Addr[i * 2 + 1] = n;
- i++;
- }
- break;
- }
-
- if (j >= 4)
- return 0;
-
- if (prevchar >= '0' && prevchar <= '9')
- base = '0';
- else if (prevchar >= 'a' && prevchar <= 'f')
- base = 'a' - 10;
- else if (prevchar >= 'A' && prevchar <= 'F')
- base = 'A' - 10;
- else
- return 0;
- n <<= 4;
- n |= (prevchar - base);
- j++;
- }
-
- if (prevchar == 0)
- break;
-
- if (input[pos] == ':') {
- pos ++;
- // sequence of zeros
- if (prevchar != ':')
- return 0;
-
- if (shiftpos != -1)
- return 0;
-
- shiftpos = i;
- }
- }
-
- if (shiftpos != -1) {
- if (i >= 7)
- return 0;
- i--;
- j = 0;
- while (i >= shiftpos) {
- output->addr.ipv6Addr[15 - (j*2) - 1] =
- output->addr.ipv6Addr[i * 2 + 0];
- output->addr.ipv6Addr[15 - (j*2) - 0] =
- output->addr.ipv6Addr[i * 2 + 1];
- output->addr.ipv6Addr[i * 2 + 0] = 0;
- output->addr.ipv6Addr[i * 2 + 1] = 0;
- i--;
- j++;
- }
- }
+ if (virSocketParseIpv6Addr(input, &output->addr) == -1)
+ return 0;
return 1;
}
@@ -1442,11 +1330,10 @@ virNWFilterRuleDetailsParse(virConnectPt
} else
rc = -1;
} else {
- if (checkIPv4Mask(datatype,
- ipaddr.addr.ipv4Addr, nwf))
- *(uint8_t *)storage_ptr =
- getMaskNumBits(ipaddr.addr.ipv4Addr,
- sizeof(ipaddr.addr.ipv4Addr));
+ int_val = virSocketGetNumNetmaskBits(
+ &ipaddr.addr);
+ if (int_val >= 0)
+ *(uint8_t *)storage_ptr = int_val;
else
rc = -1;
found = 1;
@@ -1497,11 +1384,10 @@ virNWFilterRuleDetailsParse(virConnectPt
} else
rc = -1;
} else {
- if (checkIPv6Mask(datatype,
- ipaddr.addr.ipv6Addr, nwf))
- *(uint8_t *)storage_ptr =
- getMaskNumBits(ipaddr.addr.ipv6Addr,
- sizeof(ipaddr.addr.ipv6Addr));
+ int_val = virSocketGetNumNetmaskBits(
+ &ipaddr.addr);
+ if (int_val >= 0)
+ *(uint8_t *)storage_ptr = int_val;
else
rc = -1;
found = 1;
@@ -2571,43 +2457,12 @@ virNWFilterPoolObjDeleteDef(virConnectPt
static void
virNWIPAddressFormat(virBufferPtr buf, nwIPAddressPtr ipaddr)
{
- if (!ipaddr->isIPv6) {
- virBufferVSprintf(buf, "%d.%d.%d.%d",
- ipaddr->addr.ipv4Addr[0],
- ipaddr->addr.ipv4Addr[1],
- ipaddr->addr.ipv4Addr[2],
- ipaddr->addr.ipv4Addr[3]);
- } else {
- int i;
- int dcshown = 0, in_dc = 0;
- unsigned short n;
- while (i < 8) {
- n = (ipaddr->addr.ipv6Addr[i * 2 + 0] << 8) |
- ipaddr->addr.ipv6Addr[i * 2 + 1];
- if (n == 0) {
- if (!dcshown) {
- in_dc = 1;
- if (i == 0)
- virBufferAddLit(buf, ":");
- dcshown = 1;
- }
- if (in_dc) {
- i++;
- continue;
- }
- }
- if (in_dc) {
- dcshown = 1;
- virBufferAddLit(buf, ":");
- in_dc = 0;
- }
- i++;
- virBufferVSprintf(buf, "%x", n);
- if (i < 8)
- virBufferAddLit(buf, ":");
- }
- if (in_dc)
- virBufferAddLit(buf, ":");
+ virSocketAddrPtr addr = &ipaddr->addr;
+ char *output = virSocketFormatAddr(addr);
+
+ if (output) {
+ virBufferVSprintf(buf, "%s", output);
+ VIR_FREE(output);
}
}
Index: libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_ebiptables_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -144,7 +144,7 @@ printDataType(virConnectPtr conn,
nwItemDescPtr item)
{
int done;
- int i, pos, s;
+ char *data;
if (printVar(conn, vars, buf, bufsize, item, &done))
return 1;
@@ -154,30 +154,38 @@ printDataType(virConnectPtr conn,
switch (item->datatype) {
case DATATYPE_IPADDR:
- if (snprintf(buf, bufsize, "%d.%d.%d.%d",
- item->u.ipaddr.addr.ipv4Addr[0],
- item->u.ipaddr.addr.ipv4Addr[1],
- item->u.ipaddr.addr.ipv4Addr[2],
- item->u.ipaddr.addr.ipv4Addr[3]) >= bufsize) {
- virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
- _("Buffer too small for IP address"));
+ data = virSocketFormatAddr(&item->u.ipaddr.addr);
+ if (!data) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("internal IPv4 address representation "
+ "is bad"));
+ return 1;
+ }
+ if (snprintf(buf, bufsize, "%s", data) >= bufsize) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("buffer too small for IP address"));
+ VIR_FREE(data);
return 1;
}
+ VIR_FREE(data);
break;
case DATATYPE_IPV6ADDR:
- pos = 0;
- for (i = 0; i < 16; i++) {
- s = snprintf(&buf[pos], bufsize - pos, "%x%s",
- (unsigned int)item->u.ipaddr.addr.ipv6Addr[i],
- ((i & 1) && (i < 15)) ? ":" : "" );
- if (s >= bufsize - pos) {
- virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
- _("Buffer too small for IPv6 address"));
- return 1;
- }
- pos += s;
+ data = virSocketFormatAddr(&item->u.ipaddr.addr);
+ if (!data) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("internal IPv6 address representation "
+ "is bad"));
+ return 1;
+ }
+
+ if (snprintf(buf, bufsize, "%s", data) >= bufsize) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("buffer too small for IPv6 address"));
+ VIR_FREE(data);
+ return 1;
}
+ VIR_FREE(data);
break;
case DATATYPE_MACADDR:
2
1
30 Mar '10
This patch removes the driver dependency from nwfilter_conf.c and moves
a callback function calling into the driver into
nwfilter_gentech_driver.c and passes a pointer to that callback function
upon initialization of nwfilter_conf.c.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
Index: libvirt-acl/src/conf/nwfilter_conf.c
===================================================================
--- libvirt-acl.orig/src/conf/nwfilter_conf.c
+++ libvirt-acl/src/conf/nwfilter_conf.c
@@ -39,7 +39,6 @@
#include "nwfilter_params.h"
#include "nwfilter_conf.h"
#include "domain_conf.h"
-#include "nwfilter/nwfilter_gentech_driver.h"
#define VIR_FROM_THIS VIR_FROM_NWFILTER
@@ -2064,56 +2063,7 @@ virNWFilterRegisterCallbackDriver(virNWF
}
-enum UpdateStep {
- STEP_APPLY_NEW,
- STEP_TEAR_NEW,
- STEP_TEAR_OLD,
-};
-
-struct cbStruct {
- virConnectPtr conn;
- enum UpdateStep step;
- int err;
-};
-
-static void
-virNWFilterDomainFWUpdateCB(void *payload,
- const char *name ATTRIBUTE_UNUSED,
- void *data)
-{
- virDomainObjPtr obj = payload;
- virDomainDefPtr vm = obj->def;
- struct cbStruct *cb = data;
- int i;
-
- virDomainObjLock(obj);
-
- if (virDomainObjIsActive(obj)) {
- for (i = 0; i < vm->nnets; i++) {
- virDomainNetDefPtr net = vm->nets[i];
- if ((net->filter) && (net->ifname)) {
- switch (cb->step) {
- case STEP_APPLY_NEW:
- cb->err = virNWFilterUpdateInstantiateFilter(cb->conn,
- net);
- break;
-
- case STEP_TEAR_NEW:
- cb->err = virNWFilterRollbackUpdateFilter(cb->conn, net);
- break;
-
- case STEP_TEAR_OLD:
- cb->err = virNWFilterTearOldFilter(cb->conn, net);
- break;
- }
- if (cb->err)
- break;
- }
- }
- }
-
- virDomainObjUnlock(obj);
-}
+static virHashIterator virNWFilterDomainFWUpdateCB;
static int
@@ -2121,7 +2071,7 @@ virNWFilterTriggerVMFilterRebuild(virCon
{
int i;
int err;
- struct cbStruct cb = {
+ struct domUpdateCBStruct cb = {
.conn = conn,
.err = 0,
.step = STEP_APPLY_NEW,
@@ -2717,8 +2667,10 @@ char *virNWFilterConfigFile(virConnectPt
}
-int virNWFilterConfLayerInit(void)
+int virNWFilterConfLayerInit(virHashIterator domUpdateCB)
{
+ virNWFilterDomainFWUpdateCB = domUpdateCB;
+
if (virMutexInit(&updateMutex))
return 1;
Index: libvirt-acl/src/conf/nwfilter_conf.h
===================================================================
--- libvirt-acl.orig/src/conf/nwfilter_conf.h
+++ libvirt-acl/src/conf/nwfilter_conf.h
@@ -402,6 +402,19 @@ struct _virNWFilterRuleInst {
};
+enum UpdateStep {
+ STEP_APPLY_NEW,
+ STEP_TEAR_NEW,
+ STEP_TEAR_OLD,
+};
+
+struct domUpdateCBStruct {
+ virConnectPtr conn;
+ enum UpdateStep step;
+ int err;
+};
+
+
enum virDomainNetType;
typedef int (*virNWFilterRuleCreateInstance)(virConnectPtr conn,
@@ -516,7 +529,7 @@ virNWFilterDefPtr virNWFilterDefParseFil
void virNWFilterPoolObjLock(virNWFilterPoolObjPtr obj);
void virNWFilterPoolObjUnlock(virNWFilterPoolObjPtr obj);
-int virNWFilterConfLayerInit(void);
+int virNWFilterConfLayerInit(virHashIterator domUpdateCB);
void virNWFilterConfLayerShutdown(void);
int virNWFilterParamConfLayerInit(void);
Index: libvirt-acl/src/nwfilter/nwfilter_driver.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_driver.c
@@ -34,6 +34,7 @@
#include "memory.h"
#include "domain_conf.h"
#include "nwfilter_driver.h"
+#include "nwfilter_gentech_driver.h"
#define VIR_FROM_THIS VIR_FROM_NWFILTER
@@ -64,7 +65,7 @@ static int
nwfilterDriverStartup(int privileged) {
char *base = NULL;
- if (virNWFilterConfLayerInit() < 0)
+ if (virNWFilterConfLayerInit(virNWFilterDomainFWUpdateCB) < 0)
return -1;
if (VIR_ALLOC(driverState) < 0)
Index: libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_gentech_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c
@@ -681,3 +681,43 @@ virNWFilterTeardownFilter(const virDomai
return 0;
}
+
+
+void
+virNWFilterDomainFWUpdateCB(void *payload,
+ const char *name ATTRIBUTE_UNUSED,
+ void *data)
+{
+ virDomainObjPtr obj = payload;
+ virDomainDefPtr vm = obj->def;
+ struct domUpdateCBStruct *cb = data;
+ int i;
+
+ virDomainObjLock(obj);
+
+ if (virDomainObjIsActive(obj)) {
+ for (i = 0; i < vm->nnets; i++) {
+ virDomainNetDefPtr net = vm->nets[i];
+ if ((net->filter) && (net->ifname)) {
+ switch (cb->step) {
+ case STEP_APPLY_NEW:
+ cb->err = virNWFilterUpdateInstantiateFilter(cb->conn,
+ net);
+ break;
+
+ case STEP_TEAR_NEW:
+ cb->err = virNWFilterRollbackUpdateFilter(cb->conn, net);
+ break;
+
+ case STEP_TEAR_OLD:
+ cb->err = virNWFilterTearOldFilter(cb->conn, net);
+ break;
+ }
+ if (cb->err)
+ break;
+ }
+ }
+ }
+
+ virDomainObjUnlock(obj);
+}
Index: libvirt-acl/src/nwfilter/nwfilter_gentech_driver.h
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_gentech_driver.h
+++ libvirt-acl/src/nwfilter/nwfilter_gentech_driver.h
@@ -51,4 +51,8 @@ int virNWFilterTeardownFilter(const virD
virNWFilterHashTablePtr virNWFilterCreateVarHashmap(virConnectPtr conn,
char *macaddr);
+void virNWFilterDomainFWUpdateCB(void *payload,
+ const char *name ATTRIBUTE_UNUSED,
+ void *data);
+
#endif
2
1
As discussed previously this implement hook scripts which
may be called from libvirtd at specific times.
The script are supposed to be small, execute fast as it's synchronous,
their exit value is 0 otherwise it's considered a failure (which may
be ignored but in general will stops the ongoing operation).
Scripts are stored under
/etc/libvirt/hook/
(or rather $SYSCONF_DIR/libvirt/hook/)
if missing no script invocation will ever be done. There is one script
per 'driver' there is currently hooks for the daemon, qemu and lxc,
so right now only
/etc/libvirt/hook/daemon
/etc/libvirt/hook/qemu
/etc/libvirt/hook/lxc
are potentially used. The implemented set of operations is rather simple
currently daemon start, reload, and exit, and for domain operations,
domain startup and exit.
This can be extended to more drivers in the future of more fine-grained
modularity for the scripts.
The current API to the script israther simple it get passed arguments
about the object name, the operation name, suboperation, and an extra
string. Right now for the daemon the script would get the fallowing
calls:
/etc/libvirt/hooks/daemon - start - start
/etc/libvirt/hooks/daemon - reload begin SIGHUP
/etc/libvirt/hooks/daemon - shutdown - shutdown
and for qemu (or lxc):
/etc/libvirt/hooks/qemu RHEL-5.4-64 start begin -
/etc/libvirt/hooks/qemu RHEL-5.4-64 stopped end -
with the XML configuration of the domain passed on the script stdin if
needed.
In case of script failure at domain startup, this is raised as an normal
error, e.g.:
[root@paphio tmp]# virsh start RHEL-5.4-64
error: Failed to start domain RHEL-5.4-64
error: Hook script execution failed: Hook script /etc/libvirt/hooks/qemu
qemu failed with error code 256:forbidden startup
[root@paphio tmp]#
Some hooks could certainly be added at different place in domain
lifetime operations, for example we plan to add some for migration,
but one thing to remember is that those synchronous scripts can have
a serious impact on execution, so to some extend it's better to use the
asynchronous async event mechanism when possible.
Among the things left to improve and check, there is the behaviour
when the daemon is started by the user for example for qemu:///user
and double check some of the script interaction with security, SELinux
in particular.
But the basics are there, and I would hope to have this in the next
release,
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/
4
23
All,
My recent patch to remove qemudDomainSetMaxMem() revealed some surprising
(to me) behavior of "virsh setmaxmem". In particular, if you run setmaxmem, and
the hypervisor doesn't support it, this fact will be reported to you. However,
if the amount you were setting for maxmem happens to be lower than "currentMemory",
setmaxmem will silently balloon down the domain for you. This is a surprising
result exactly because virsh reports error, but did something anyway. What I
would expect is that if a hypervisor doesn't support virDomainSetMaxMem(), nothing
at all is done.
If we agree that this is behavior that needs to be fixed, I would suggest
that we move the code to do the auto-ballooning into each of the individual
drivers that *do* support virDomainSetMaxMem(). Currently that includes the
test driver, the LXC driver, and the Xen driver. This way, we maintain the
current behavior for the hypervisors that support this call, and make sure
not to do anything at all for the hypervisors that do not.
Opinions?
--
Chris Lalancette
3
4
30 Mar '10
This patchset implements the XML described in
http://www.redhat.com/archives/libvir-list/2010-March/msg00304.html
(with one small change - the tickpolicy 'none' was changed to 'delay'
after a later discussion).
It also implements the qemu backend for those timer types that qemu supports.
One thing to point out to 'early adopters': qemu's driftfix option is
currently broken, so if you try to specify a tickpolicy=catchup in an
rtc timer, the domain will give an error on startup. A patch for that
has been posted by Zach Amsden to qemu-devel:
http://lists.gnu.org/archive/html/qemu-devel/2010-03/msg02036.html
Backends for other hypervisors have not been implemented. That is left
as an exercise for later ;-)
2
5
On IRC yesterday, the comment came up that 'virsh edit' is
over-protective, because it prevented me from editing in-terminal
using my favorite editor, even after I worked around the fact that
sudo sanitizes EDITOR. Besides, historically, VISUAL is used in
situations where opening a new window is okay, while EDITOR is used
when editing should reuse the current terminal; so we should honor
that convention.
3
7
30 Mar '10
Extend tests to cover all SCSI controller types and document the new type.
---
docs/drvesx.html.in | 4 +++
src/esx/esx_vmx.c | 14 +++++++-----
tests/vmx2xmldata/vmx2xml-scsi-buslogic.vmx | 7 ------
tests/vmx2xmldata/vmx2xml-scsi-buslogic.xml | 20 ------------------
tests/vmx2xmldata/vmx2xml-scsi-driver.vmx | 17 +++++++++++++++
tests/vmx2xmldata/vmx2xml-scsi-driver.xml | 30 +++++++++++++++++++++++++++
tests/vmx2xmltest.c | 2 +-
tests/xml2vmxdata/xml2vmx-scsi-buslogic.vmx | 12 ----------
tests/xml2vmxdata/xml2vmx-scsi-buslogic.xml | 15 -------------
tests/xml2vmxdata/xml2vmx-scsi-driver.vmx | 22 +++++++++++++++++++
tests/xml2vmxdata/xml2vmx-scsi-driver.xml | 25 ++++++++++++++++++++++
tests/xml2vmxtest.c | 2 +-
12 files changed, 108 insertions(+), 62 deletions(-)
delete mode 100644 tests/vmx2xmldata/vmx2xml-scsi-buslogic.vmx
delete mode 100644 tests/vmx2xmldata/vmx2xml-scsi-buslogic.xml
create mode 100644 tests/vmx2xmldata/vmx2xml-scsi-driver.vmx
create mode 100644 tests/vmx2xmldata/vmx2xml-scsi-driver.xml
delete mode 100644 tests/xml2vmxdata/xml2vmx-scsi-buslogic.vmx
delete mode 100644 tests/xml2vmxdata/xml2vmx-scsi-buslogic.xml
create mode 100644 tests/xml2vmxdata/xml2vmx-scsi-driver.vmx
create mode 100644 tests/xml2vmxdata/xml2vmx-scsi-driver.xml
diff --git a/docs/drvesx.html.in b/docs/drvesx.html.in
index 44a144f..9b413ab 100644
--- a/docs/drvesx.html.in
+++ b/docs/drvesx.html.in
@@ -275,6 +275,10 @@ ethernet0.checkMACAddress = "false"
<dd>
LSI Logic SCSI controller for recent guests.
</dd>
+ <dt><code>lsisas1068</code></dt>
+ <dd>
+ LSI Logic SAS 1068 controller.
+ </dd>
</dl>
<p>
Here a domain XML snippet:
diff --git a/src/esx/esx_vmx.c b/src/esx/esx_vmx.c
index ba4c608..6c1d56e 100644
--- a/src/esx/esx_vmx.c
+++ b/src/esx/esx_vmx.c
@@ -557,10 +557,11 @@ esxVMX_GatherSCSIControllers(virDomainDefPtr def, char *virtualDev[4],
if (disk->driverName != NULL &&
STRCASENEQ(disk->driverName, "buslogic") &&
- STRCASENEQ(disk->driverName, "lsilogic")) {
+ STRCASENEQ(disk->driverName, "lsilogic") &&
+ STRCASENEQ(disk->driverName, "lsisas1068")) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
"Expecting domain XML entry 'devices/disk/target' to be "
- "'buslogic' or 'lsilogic' but found '%s'",
+ "'buslogic' or 'lsilogic' or 'lsisas1068' but found '%s'",
disk->driverName);
return -1;
}
@@ -1269,10 +1270,11 @@ esxVMX_ParseSCSIController(virConfPtr conf, int controller, int *present,
if (*virtualDev != NULL &&
STRCASENEQ(*virtualDev, "buslogic") &&
- STRCASENEQ(*virtualDev, "lsilogic")) {
+ STRCASENEQ(*virtualDev, "lsilogic") &&
+ STRCASENEQ(*virtualDev, "lsisas1068")) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- "Expecting VMX entry '%s' to be 'buslogic' or 'lsilogic' "
- "but found '%s'", virtualDev_name, *virtualDev);
+ "Expecting VMX entry '%s' to be 'buslogic' or 'lsilogic' or "
+ "'lsisas1068' but found '%s'", virtualDev_name, *virtualDev);
goto failure;
}
@@ -1312,7 +1314,7 @@ esxVMX_ParseDisk(esxVI_Context *ctx, virConfPtr conf, int device, int bus,
* bus = VIR_DOMAIN_DISK_BUS_SCSI
* controller = [0..3]
* id = [0..6,8..15]
- * virtualDev = {'buslogic', 'lsilogic'}
+ * virtualDev = {'buslogic', 'lsilogic', 'lsisas1068'}
*
* device = {VIR_DOMAIN_DISK_DEVICE_DISK, VIR_DOMAIN_DISK_DEVICE_CDROM}
* bus = VIR_DOMAIN_DISK_BUS_IDE
diff --git a/tests/vmx2xmldata/vmx2xml-scsi-buslogic.vmx b/tests/vmx2xmldata/vmx2xml-scsi-buslogic.vmx
deleted file mode 100644
index 1725051..0000000
--- a/tests/vmx2xmldata/vmx2xml-scsi-buslogic.vmx
+++ /dev/null
@@ -1,7 +0,0 @@
-config.version = "8"
-virtualHW.version = "4"
-scsi0.present = "true"
-scsi0.virtualDev = "buslogic"
-scsi0:0.present = "true"
-scsi0:0.deviceType = "scsi-hardDisk"
-scsi0:0.fileName = "harddisk.vmdk"
diff --git a/tests/vmx2xmldata/vmx2xml-scsi-buslogic.xml b/tests/vmx2xmldata/vmx2xml-scsi-buslogic.xml
deleted file mode 100644
index 2ffb866..0000000
--- a/tests/vmx2xmldata/vmx2xml-scsi-buslogic.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<domain type='vmware'>
- <uuid>00000000-0000-0000-0000-000000000000</uuid>
- <memory>32768</memory>
- <currentMemory>32768</currentMemory>
- <vcpu>1</vcpu>
- <os>
- <type arch='i686'>hvm</type>
- </os>
- <clock offset='utc'/>
- <on_poweroff>destroy</on_poweroff>
- <on_reboot>restart</on_reboot>
- <on_crash>destroy</on_crash>
- <devices>
- <disk type='file' device='disk'>
- <driver name='buslogic'/>
- <source file='[datastore] directory/harddisk.vmdk'/>
- <target dev='sda' bus='scsi'/>
- </disk>
- </devices>
-</domain>
diff --git a/tests/vmx2xmldata/vmx2xml-scsi-driver.vmx b/tests/vmx2xmldata/vmx2xml-scsi-driver.vmx
new file mode 100644
index 0000000..cb055f6
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-scsi-driver.vmx
@@ -0,0 +1,17 @@
+config.version = "8"
+virtualHW.version = "4"
+scsi0.present = "true"
+scsi0.virtualDev = "buslogic"
+scsi1.present = "true"
+scsi1.virtualDev = "lsilogic"
+scsi2.present = "true"
+scsi2.virtualDev = "lsisas1068"
+scsi0:0.present = "true"
+scsi0:0.deviceType = "scsi-hardDisk"
+scsi0:0.fileName = "harddisk1.vmdk"
+scsi1:0.present = "true"
+scsi1:0.deviceType = "scsi-hardDisk"
+scsi1:0.fileName = "harddisk2.vmdk"
+scsi2:0.present = "true"
+scsi2:0.deviceType = "scsi-hardDisk"
+scsi2:0.fileName = "harddisk3.vmdk"
diff --git a/tests/vmx2xmldata/vmx2xml-scsi-driver.xml b/tests/vmx2xmldata/vmx2xml-scsi-driver.xml
new file mode 100644
index 0000000..1fa9ac4
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-scsi-driver.xml
@@ -0,0 +1,30 @@
+<domain type='vmware'>
+ <uuid>00000000-0000-0000-0000-000000000000</uuid>
+ <memory>32768</memory>
+ <currentMemory>32768</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686'>hvm</type>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <disk type='file' device='disk'>
+ <driver name='buslogic'/>
+ <source file='[datastore] directory/harddisk1.vmdk'/>
+ <target dev='sda' bus='scsi'/>
+ </disk>
+ <disk type='file' device='disk'>
+ <driver name='lsilogic'/>
+ <source file='[datastore] directory/harddisk2.vmdk'/>
+ <target dev='sdp' bus='scsi'/>
+ </disk>
+ <disk type='file' device='disk'>
+ <driver name='lsisas1068'/>
+ <source file='[datastore] directory/harddisk3.vmdk'/>
+ <target dev='sdae' bus='scsi'/>
+ </disk>
+ </devices>
+</domain>
diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c
index b4eb5d5..e75def4 100644
--- a/tests/vmx2xmltest.c
+++ b/tests/vmx2xmltest.c
@@ -122,7 +122,7 @@ mymain(int argc, char **argv)
DO_TEST("graphics-vnc", "graphics-vnc", esxVI_APIVersion_25);
- DO_TEST("scsi-buslogic", "scsi-buslogic", esxVI_APIVersion_25);
+ DO_TEST("scsi-driver", "scsi-driver", esxVI_APIVersion_25);
DO_TEST("scsi-writethrough", "scsi-writethrough", esxVI_APIVersion_25);
DO_TEST("harddisk-scsi-file", "harddisk-scsi-file", esxVI_APIVersion_25);
diff --git a/tests/xml2vmxdata/xml2vmx-scsi-buslogic.vmx b/tests/xml2vmxdata/xml2vmx-scsi-buslogic.vmx
deleted file mode 100644
index 2f98da3..0000000
--- a/tests/xml2vmxdata/xml2vmx-scsi-buslogic.vmx
+++ /dev/null
@@ -1,12 +0,0 @@
-config.version = "8"
-virtualHW.version = "4"
-guestOS = "other"
-uuid.bios = "56 4d 9b ef ac d9 b4 e0-c8 f0 ae a8 b9 10 35 15"
-displayName = "scsi-buslogic"
-memsize = "4"
-numvcpus = "1"
-scsi0.present = "true"
-scsi0.virtualDev = "buslogic"
-scsi0:0.present = "true"
-scsi0:0.deviceType = "scsi-hardDisk"
-scsi0:0.fileName = "/vmfs/volumes/datastore/directory/harddisk.vmdk"
diff --git a/tests/xml2vmxdata/xml2vmx-scsi-buslogic.xml b/tests/xml2vmxdata/xml2vmx-scsi-buslogic.xml
deleted file mode 100644
index 5d52c54..0000000
--- a/tests/xml2vmxdata/xml2vmx-scsi-buslogic.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<domain type='vmware'>
- <name>scsi-buslogic</name>
- <uuid>564d9bef-acd9-b4e0-c8f0-aea8b9103515</uuid>
- <memory>4096</memory>
- <os>
- <type>hvm</type>
- </os>
- <devices>
- <disk type='file' device='disk'>
- <driver name='buslogic'/>
- <source file='[datastore] directory/harddisk.vmdk'/>
- <target dev='sda' bus='scsi'/>
- </disk>
- </devices>
-</domain>
diff --git a/tests/xml2vmxdata/xml2vmx-scsi-driver.vmx b/tests/xml2vmxdata/xml2vmx-scsi-driver.vmx
new file mode 100644
index 0000000..7cceca0
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-scsi-driver.vmx
@@ -0,0 +1,22 @@
+config.version = "8"
+virtualHW.version = "4"
+guestOS = "other"
+uuid.bios = "56 4d 9b ef ac d9 b4 e0-c8 f0 ae a8 b9 10 35 15"
+displayName = "scsi-buslogic"
+memsize = "4"
+numvcpus = "1"
+scsi0.present = "true"
+scsi0.virtualDev = "buslogic"
+scsi1.present = "true"
+scsi1.virtualDev = "lsilogic"
+scsi2.present = "true"
+scsi2.virtualDev = "lsisas1068"
+scsi0:0.present = "true"
+scsi0:0.deviceType = "scsi-hardDisk"
+scsi0:0.fileName = "/vmfs/volumes/datastore/directory/harddisk1.vmdk"
+scsi1:0.present = "true"
+scsi1:0.deviceType = "scsi-hardDisk"
+scsi1:0.fileName = "/vmfs/volumes/datastore/directory/harddisk2.vmdk"
+scsi2:0.present = "true"
+scsi2:0.deviceType = "scsi-hardDisk"
+scsi2:0.fileName = "/vmfs/volumes/datastore/directory/harddisk3.vmdk"
diff --git a/tests/xml2vmxdata/xml2vmx-scsi-driver.xml b/tests/xml2vmxdata/xml2vmx-scsi-driver.xml
new file mode 100644
index 0000000..797a26e
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-scsi-driver.xml
@@ -0,0 +1,25 @@
+<domain type='vmware'>
+ <name>scsi-buslogic</name>
+ <uuid>564d9bef-acd9-b4e0-c8f0-aea8b9103515</uuid>
+ <memory>4096</memory>
+ <os>
+ <type>hvm</type>
+ </os>
+ <devices>
+ <disk type='file' device='disk'>
+ <driver name='buslogic'/>
+ <source file='[datastore] directory/harddisk1.vmdk'/>
+ <target dev='sda' bus='scsi'/>
+ </disk>
+ <disk type='file' device='disk'>
+ <driver name='lsilogic'/>
+ <source file='[datastore] directory/harddisk2.vmdk'/>
+ <target dev='sdp' bus='scsi'/>
+ </disk>
+ <disk type='file' device='disk'>
+ <driver name='lsisas1068'/>
+ <source file='[datastore] directory/harddisk3.vmdk'/>
+ <target dev='sdae' bus='scsi'/>
+ </disk>
+ </devices>
+</domain>
diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c
index b8b9d6f..f9c4730 100644
--- a/tests/xml2vmxtest.c
+++ b/tests/xml2vmxtest.c
@@ -175,7 +175,7 @@ mymain(int argc, char **argv)
DO_TEST("graphics-vnc", "graphics-vnc", esxVI_APIVersion_25);
- DO_TEST("scsi-buslogic", "scsi-buslogic", esxVI_APIVersion_25);
+ DO_TEST("scsi-driver", "scsi-driver", esxVI_APIVersion_25);
DO_TEST("scsi-writethrough", "scsi-writethrough", esxVI_APIVersion_25);
DO_TEST("harddisk-scsi-file", "harddisk-scsi-file", esxVI_APIVersion_25);
--
1.6.3.3
2
5
So clearly we are a bit late we didn't freezed this week-end,
hopefully we can push the last bits for the release tomorrow.
I would be tempted to actually name the release 0.8.0 if we get
the snapshot API in (which I expect), then start freeze on Wed,
and make the official release early next week. There is still a few
things to clean up left and right, some patches for bug fixes need
ACKs, so I still expect some work before being able to declare the
new release ready !
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/
1
0
29 Mar '10
Another one caught by clang:
Note the first test to see if "inst" may be NULL.
Then, in the following loop, "inst" is unconditionally
dereferenced via "inst[i]". There are other unprotected
used of "inst[i]" below, too.
Rather than trying to protect all uses, one by one, I chose
to return "success" when given an empty list of rules.
In addition, not only does it appear to be possible to call
this function with a NULL "inst" pointer, but it may even
be undefined. At least one caller is virNWFilterInstantiate,
where "inst" maps to the caller's "ptrs" variable. There,
ptrs is initialized (or not, in some cases) by
virNWFilterRuleInstancesToArray. Fortunately, at least
this one caller (virNWFilterRuleInstancesToArray) does
initialize "ptrs" to NULL, so in actuality, it cannot currently
be used undefined. But the fact that a function like
virNWFilterRuleInstancesToArray can return "successfully"
without defining that output parameter is a little risky.
>From f2d1a49095ed6f7caa3d5ee67409ac561c55ba77 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Mon, 29 Mar 2010 18:27:26 +0200
Subject: [PATCH] nwfilter_ebiptables_driver.c: avoid NULL dereference
* src/nwfilter/nwfilter_ebiptables_driver.c (ebiptablesApplyNewRules):
Don't dereference a NULL or uninitialized pointer when given
an empty list of rules
---
src/nwfilter/nwfilter_ebiptables_driver.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfilter_ebiptables_driver.c
index 7871926..3932b44 100644
--- a/src/nwfilter/nwfilter_ebiptables_driver.c
+++ b/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -2378,31 +2378,32 @@ ebiptablesRuleOrderSort(const void *a, const void *b)
static int
ebiptablesApplyNewRules(virConnectPtr conn,
const char *ifname,
int nruleInstances,
void **_inst)
{
int i;
int cli_status;
ebiptablesRuleInstPtr *inst = (ebiptablesRuleInstPtr *)_inst;
int chains_in = 0, chains_out = 0;
virBuffer buf = VIR_BUFFER_INITIALIZER;
int haveIptables = 0;
- if (inst)
- qsort(inst, nruleInstances, sizeof(inst[0]),
- ebiptablesRuleOrderSort);
+ if (nruleInstances == 0 || inst == NULL)
+ return 0;
+
+ qsort(inst, nruleInstances, sizeof(inst[0]), ebiptablesRuleOrderSort);
for (i = 0; i < nruleInstances; i++) {
if (inst[i]->ruleType == RT_EBTABLES) {
if (inst[i]->chainprefix == CHAINPREFIX_HOST_IN_TEMP)
chains_in |= (1 << inst[i]->neededProtocolChain);
else
chains_out |= (1 << inst[i]->neededProtocolChain);
}
}
ebtablesUnlinkTmpRootChain(conn, &buf, 1, ifname);
ebtablesUnlinkTmpRootChain(conn, &buf, 0, ifname);
ebtablesRemoveTmpSubChains(conn, &buf, ifname);
ebtablesRemoveTmpRootChain(conn, &buf, 1, ifname);
--
1.7.0.3.448.g82eeb
4
7
This fix makes the int-overflow test case pass.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
Index: libvirt/tests/int-overflow
===================================================================
--- libvirt.orig/tests/int-overflow
+++ libvirt/tests/int-overflow
@@ -14,6 +14,7 @@ fi
. "$srcdir/test-lib.sh"
echo "error: failed to get domain '4294967298'" > exp || fail=1
+echo "error: Failed to start the nwfilter driver: Is the daemon running ?" >> exp || fail=1
echo domname 4294967298 | $abs_top_builddir/tools/virsh --quiet \
--connect test://$abs_top_srcdir/examples/xml/test/testnode.xml \
> /dev/null 2> err || fail=1
3
4
[libvirt] [PATCH v4 00/15] Network filtering (ACL) extensions for libvirt
by Stefan Berger 29 Mar '10
by Stefan Berger 29 Mar '10
29 Mar '10
Hi!
This is a repost of this set of patches with some of the suggested fixes
applied and ipv6 support on the ebtables layer added.
Between V3 and V4 of this patch series the following changes were made:
- occurrences of typo 'scp' were changed to 'sctp'
- the root ebtables chain for each interface now has the previx of 'libvirt-'
- additional calls into tear-down functions in case something goes wrong
while starting the qemu/kvm VM in 2nd level error paths
- additional functions in the driver interface to split up the application
of firewall rules into
- creation of new firewall rules 'tree'
- switch-over to new firewall rules 'tree', tear down of old one and
renaming of new firewall 'tree'
- tear down of new firewall rules 'tree' in case an error happend
during update of several VMs.
- additional patch with example filters
The following set of patches add network filtering (ACL) extensions to
libvirt and enable network traffic filtering for VMs using ebtables and,
depending on the networking technology being used (tap, but not
macvtap), also iptables. Usage of either is optional and controlled
through filters that a VM is referencing.
The ebtables-level filtering is based on the XML derived from the CIM
network slide 10 (filtering) from the DMTF website
(http://www.dmtf.org/standards/cim/cim_schema_v2230/CIM_Network.pdf)
The XML we derived from this was discussed on the list before. On the
ebtables level we currently handle filtering of IPv4 and ARP traffic.
The iptables-level filtering is based on similar XML where XML nodes
described the particular protocol to filter for. Its extensions enable
the filtering of traffic using iptables for tcp, udp, icmp, igmp, sctp
and 'all' types of traffic. This list of protocols maps to the features
supported by iptables and only excludes protocols like 'esp', 'ah' and
'udplite'. Currently only bridging mode is supported and based on
availability of the physdev match.
The filtering framework adds new libvirt virsh commands for managing
the filters. The 5 new commands are:
- virsh nwfilter-list
- virsh nwfilter-dumpxml <name of filter>
- virsh nwfilter-define <name of file containing filter desc.>
- virsh nwfilter-undefine <name of filter>
- virsh nwfilter-edit <name of filter>
Above commands are similar to commands for already existing pools and as
such much of the code directly related to the above commands could be
borrowed from other drivers.
The network filters can either contain rules using the above mentioned
XML or contain references to other filters in order to build more
complex filters that form some sort of filter tree or can contain both.
An example for a filter referencing other filters would be this one
here:
<filter name='demofilter4' chain='root'>
<uuid>66f62d1d-34c1-1421-824f-c62d5ee5e8b6</uuid>
<filterref filter='no-mac-spoofing'/>
<filterref filter='no-mac-broadcast'/>
<filterref filter='no-arp-spoofing'/>
<filterref filter='allow-dhcp'>
<parameter name='DHCPSERVER' value='10.0.0.1'/>
</filterref>
<filterref filter='no-other-l2-traffic'/>
<filterref filter='recv-only-vm-ipaddress'/>
<filterref filter='recv-only-vm-macaddress'/>
<filterref filter='l3-test'/>
<filterref filter='ipv6test'/>
</filter>
A filter containing actual rules would look like this:
<filter name='no-mac-broadcast' chain='ipv4'>
<uuid>ffe2ccd6-edec-7360-1852-6b5ccb553234</uuid>
<rule action='drop' direction='out' priority='500'>
<mac dstmacaddr='ff:ff:ff:ff:ff:ff'/>
</rule>
</filter>
The filter XML now also holds a priority attribute in the rule. This
provides control over the ordering of the applied ebtables/iptables
rules beyond their appearance in the XML.
The domain XML has been extended to reference a top level filter from
within each <interface> XML node. A valid reference to such a top level
filter looks like this:
<interface type='bridge'>
<source bridge='static'/>
<filterref filter='demofilter4'>
<parameter name='IP' value='9.59.241.151'/>
</filterref>
</interface>
In this XML a parameter IP is passed for instantiation of the referenced
filters, that may require the availability of this parameter. In the
above case the IP parameter's value describes the value of the IP
address of the VM and allows to enable those filters to be instantiated
that require this 'IP' variable. If a filter requires a parameter that
is not provided, the VM will not start or the interface will not attach
to a running VM. Any names of parameters can be provided for
instantiation of filters and their names and values only need to pass a
regular expression test. In a subsequent patch we will be adding
capability to allow users to omit the IP parameter (only) and enable
libvirt to learn the IP address of the VM and have it instantiate the
filter once it knows it.
While virtual machines are running, it is possible to update their
filters. For that all running VMs' filter 'trees' are traversed to
detect whether the updated filter is referenced by the VM. If so, its
ebtables/iptable rules are applied. If one of the VMs' update fails
allupdates are rolled back and the filter XML update is rejected.
One comment about the instantiation of the rules: Since the XML allows
to create nearly any possible combination of parameters to ebtables or
iptables commands, I haven't used the ebtables or iptables wrappers.
Instead, I am writing ebtables/iptables command into a buffer, add
command line options to each one of them as described in the rule's XML,
write the buffer into a file and run it as a script. For those commands
that are not allowed to fail I am using the following format to run
them:
cmd="ebtables <some options>"
r=`${cmd}`
if [ $? -ne 0 ]; then
echo "Failure in command ${cmd}."
exit 1
fi
cmd="..."
[...]
If one of the command fails in such a batch, the libvirt code is going
pick up the error code '1', tear down anything previously established
and report an error back. The actual error message shown above is
currently not reported back, but can be later on with some changes to
the commands running external programs that need to read the script's
stdout.
One comment to patch 14: It currently #include's a .c file into a .c
file only for the reason so I don't have to change too much code once I
change code in the underlying patch. So this has to be changed. The
patch series works without patch 13, but then only supports ebtables.
The patches apply to the current tip. They pass 'make syntax-check' and
have been frequently run in valgrind for memory leak checks.
Looking forward to your feedback on the patches.
Thanks and regards,
Stefan and Gerhard
3
21
[libvirt] [PATCH] nwfilter_conf.c: don't test an uninitialized local variable
by Jim Meyering 29 Mar '10
by Jim Meyering 29 Mar '10
29 Mar '10
I've just run the code through clang, and it spotted a few new problems.
Here's one:
>From 4c848787c8268e37db9a1d0754b8fcd8e5774f73 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Mon, 29 Mar 2010 17:34:32 +0200
Subject: [PATCH] nwfilter_conf.c: don't test an uninitialized local variable
* src/conf/nwfilter_conf.c (virNWIPAddressFormat): Do not use "i"
uninitialized.
---
src/conf/nwfilter_conf.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index e82aae6..f673e69 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -2423,7 +2423,7 @@ virNWIPAddressFormat(virBufferPtr buf, nwIPAddressPtr ipaddr)
ipaddr->addr.ipv4Addr[2],
ipaddr->addr.ipv4Addr[3]);
} else {
- int i;
+ unsigned int i = 0;
int dcshown = 0, in_dc = 0;
unsigned short n;
while (i < 8) {
--
1.7.0.3.448.g82eeb
3
2
[libvirt] [PATCH] Fix 'make check' runs due to usage of conn parameter in error reporting
by Stefan Berger 29 Mar '10
by Stefan Berger 29 Mar '10
29 Mar '10
This patch fixes the 'make check' runs for me which, under certain
circumstances and login configurations, did invoke popups requesting
authentication. I removed the parameter conn from being passed into the
error reporting function.
Signed-off-by; Stefan Berger <stefanb(a)us.ibm.com>
---
src/conf/nwfilter_conf.c | 15 ++++++---------
src/conf/nwfilter_conf.h | 3 ++-
2 files changed, 8 insertions(+), 10 deletions(-)
Index: libvirt/src/conf/nwfilter_conf.c
===================================================================
--- libvirt.orig/src/conf/nwfilter_conf.c
+++ libvirt/src/conf/nwfilter_conf.c
@@ -44,9 +44,6 @@
#define VIR_FROM_THIS VIR_FROM_NWFILTER
-#define virNWFilterError(conn, code, fmt...) \
- virReportErrorHelper(conn, VIR_FROM_NWFILTER, code, __FILE__,\
- __FUNCTION__, __LINE__, fmt)
VIR_ENUM_IMPL(virNWFilterRuleAction, VIR_NWFILTER_RULE_ACTION_LAST,
"drop",
@@ -2248,9 +2245,9 @@ virNWFilterPoolObjLoad(virConnectPtr con
}
if (!virFileMatchesNameSuffix(file, def->name, ".xml")) {
- virNWFilterError(conn, VIR_ERR_INVALID_NWFILTER,
- "NWFilter pool config filename '%s' does not match pool name '%s'",
- path, def->name);
+ virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
+ _("network filter pool config filename '%s' does not match pool name '%s'"),
+ path, def->name);
virNWFilterDefFree(def);
return NULL;
}
@@ -2300,9 +2297,9 @@ virNWFilterPoolLoadAllConfigs(virConnect
if (virFileBuildPath(configDir, entry->d_name,
NULL, path, PATH_MAX) < 0) {
- virNWFilterError(conn, VIR_ERR_INTERNAL_ERROR,
- "Config filename '%s/%s' is too long",
- configDir, entry->d_name);
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("config filename '%s/%s' is too long"),
+ configDir, entry->d_name);
continue;
}
Index: libvirt/src/conf/nwfilter_conf.h
===================================================================
--- libvirt.orig/src/conf/nwfilter_conf.h
+++ libvirt/src/conf/nwfilter_conf.h
@@ -523,7 +523,8 @@ int virNWFilterParamConfLayerInit(void);
void virNWFilterParamConfLayerShutdown(void);
# define virNWFilterReportError(conn, code, fmt...) \
- virReportErrorHelper(conn, VIR_FROM_NWFILTER, code, __FILE__, \
+ (void)conn; \
+ virReportErrorHelper(NULL, VIR_FROM_NWFILTER, code, __FILE__, \
__FUNCTION__, __LINE__, fmt)
1
0
Hi everyone
i've been trying to migrate a domain from hostA to hostB.But everytime i did
it with
"virsh --live migrate <Domain> xen+ssh://root@Destination",
it failed and told me something like
"Error Domain not found:xenUnifiedDomainLookupByName".
The same thing happened when i tried to do the same thing with libvirt API
like virDomainMigrate & virDomainMigrateToURI.
i am confused about this.
So can anybody can tell me why?Thanks a lot.
BTW,the OS is CentOS 5.4 with libvirt 0.7.7 and Xen 3.4.0.
2
1
[libvirt] [PATCH] filter new files through cppi, so syntax-check passes once again
by Jim Meyering 27 Mar '10
by Jim Meyering 27 Mar '10
27 Mar '10
FYI, just pushed (no semantic change):
>From d0e79bd5fa280a568d5b919fabd5f2f4dacf8f89 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Fri, 26 Mar 2010 19:29:54 +0100
Subject: [PATCH] filter new files through cppi, so syntax-check passes once again
* src/conf/nwfilter_conf.h: Indent cpp directives.
* src/conf/nwfilter_params.h: Likewise.
* src/datatypes.h: Likewise.
* src/nwfilter/nwfilter_driver.h: Likewise.
* src/nwfilter/nwfilter_ebiptables_driver.h: Likewise.
* src/nwfilter/nwfilter_gentech_driver.h: Likewise.
---
src/conf/nwfilter_conf.h | 24 ++++++++++++------------
src/conf/nwfilter_params.h | 4 ++--
src/datatypes.h | 6 +++---
src/nwfilter/nwfilter_driver.h | 6 +++---
src/nwfilter/nwfilter_ebiptables_driver.h | 6 +++---
src/nwfilter/nwfilter_gentech_driver.h | 2 +-
6 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h
index 5ba2f41..9b6ca40 100644
--- a/src/conf/nwfilter_conf.h
+++ b/src/conf/nwfilter_conf.h
@@ -24,15 +24,15 @@
* Author: Stefan Berger <stefanb(a)us.ibm.com>
*/
#ifndef NWFILTER_CONF_H
-#define NWFILTER_CONF_H
+# define NWFILTER_CONF_H
-#include <stdint.h>
-#include <stddef.h>
+# include <stdint.h>
+# include <stddef.h>
-#include "internal.h"
-#include "util.h"
-#include "hash.h"
-#include "xml.h"
+# include "internal.h"
+# include "util.h"
+# include "hash.h"
+# include "xml.h"
/**
* Chain suffix size is:
@@ -43,7 +43,7 @@
* terminating '0' =
* 32-3-15-1-1 = 12
*/
-#define MAX_CHAIN_SUFFIX_SIZE 12
+# define MAX_CHAIN_SUFFIX_SIZE 12
enum virNWFilterEntryItemFlags {
@@ -53,10 +53,10 @@ enum virNWFilterEntryItemFlags {
};
-#define HAS_ENTRY_ITEM(data) \
+# define HAS_ENTRY_ITEM(data) \
(((data)->flags) & NWFILTER_ENTRY_ITEM_FLAG_EXISTS)
-#define ENTRY_GET_NEG_SIGN(data) \
+# define ENTRY_GET_NEG_SIGN(data) \
((((data)->flags) & NWFILTER_ENTRY_ITEM_FLAG_IS_NEG) ? "!" : "")
// datatypes appearing in rule attributes
@@ -288,7 +288,7 @@ enum virNWFilterEbtablesTableType {
};
-#define MAX_RULE_PRIORITY 1000
+# define MAX_RULE_PRIORITY 1000
typedef struct _virNWFilterRuleDef virNWFilterRuleDef;
@@ -522,7 +522,7 @@ void virNWFilterConfLayerShutdown(void);
int virNWFilterParamConfLayerInit(void);
void virNWFilterParamConfLayerShutdown(void);
-#define virNWFilterReportError(conn, code, fmt...) \
+# define virNWFilterReportError(conn, code, fmt...) \
virReportErrorHelper(conn, VIR_FROM_NWFILTER, code, __FILE__, \
__FUNCTION__, __LINE__, fmt)
diff --git a/src/conf/nwfilter_params.h b/src/conf/nwfilter_params.h
index 7a9b1ee..5b4afba 100644
--- a/src/conf/nwfilter_params.h
+++ b/src/conf/nwfilter_params.h
@@ -20,9 +20,9 @@
* Author: Stefan Berger <stefanb(a)us.ibm.com>
*/
#ifndef NWFILTER_PARAMS_H
-#define NWFILTER_PARAMS_H
+# define NWFILTER_PARAMS_H
-#include "hash.h"
+# include "hash.h"
typedef struct _virNWFilterHashTable virNWFilterHashTable;
typedef virNWFilterHashTable *virNWFilterHashTablePtr;
diff --git a/src/datatypes.h b/src/datatypes.h
index c221119..4663c9c 100644
--- a/src/datatypes.h
+++ b/src/datatypes.h
@@ -126,9 +126,9 @@
* magic value used to protect the API when pointers to network filter
* pool structures are passed down by the users.
*/
-#define VIR_NWFILTER_MAGIC 0xDEAD7777
-#define VIR_IS_NWFILTER(obj) ((obj) && (obj)->magic==VIR_NWFILTER_MAGIC)
-#define VIR_IS_CONNECTED_NWFILTER(obj) (VIR_IS_NWFILTER(obj) && VIR_IS_CONNECT((obj)->conn))
+# define VIR_NWFILTER_MAGIC 0xDEAD7777
+# define VIR_IS_NWFILTER(obj) ((obj) && (obj)->magic==VIR_NWFILTER_MAGIC)
+# define VIR_IS_CONNECTED_NWFILTER(obj) (VIR_IS_NWFILTER(obj) && VIR_IS_CONNECT((obj)->conn))
/**
diff --git a/src/nwfilter/nwfilter_driver.h b/src/nwfilter/nwfilter_driver.h
index b7d8668..3f60560 100644
--- a/src/nwfilter/nwfilter_driver.h
+++ b/src/nwfilter/nwfilter_driver.h
@@ -26,10 +26,10 @@
*/
#ifndef __VIR_NWFILTER_DRIVER_H__
-#define __VIR_NWFILTER_DRIVER_H__
+# define __VIR_NWFILTER_DRIVER_H__
-#include "nwfilter_params.h"
-#include "nwfilter_conf.h"
+# include "nwfilter_params.h"
+# include "nwfilter_conf.h"
int nwfilterRegister(void);
diff --git a/src/nwfilter/nwfilter_ebiptables_driver.h b/src/nwfilter/nwfilter_ebiptables_driver.h
index a036b99..ff22844 100644
--- a/src/nwfilter/nwfilter_ebiptables_driver.h
+++ b/src/nwfilter/nwfilter_ebiptables_driver.h
@@ -21,9 +21,9 @@
* Author: Stefan Berger <stefanb(a)us.ibm.com>
*/
#ifndef VIR_NWFILTER_EBTABLES_DRIVER_H__
-#define VIR_NWFILTER_EBTABLES_DRIVER_H__
+# define VIR_NWFILTER_EBTABLES_DRIVER_H__
-#define MAX_CHAINNAME_LENGTH 32 /* see linux/netfilter_bridge/ebtables.h */
+# define MAX_CHAINNAME_LENGTH 32 /* see linux/netfilter_bridge/ebtables.h */
enum RuleType {
RT_EBTABLES,
@@ -43,6 +43,6 @@ struct _ebiptablesRuleInst {
extern virNWFilterTechDriver ebiptables_driver;
-#define EBIPTABLES_DRIVER_ID "ebiptables"
+# define EBIPTABLES_DRIVER_ID "ebiptables"
#endif
diff --git a/src/nwfilter/nwfilter_gentech_driver.h b/src/nwfilter/nwfilter_gentech_driver.h
index a77d95a..6b7da71 100644
--- a/src/nwfilter/nwfilter_gentech_driver.h
+++ b/src/nwfilter/nwfilter_gentech_driver.h
@@ -21,7 +21,7 @@
* Author: Stefan Berger <stefanb(a)us.ibm.com>
*/
#ifndef __NWFILTER_GENTECH_DRIVER_H
-#define __NWFILTER_GENTECH_DRIVER_H
+# define __NWFILTER_GENTECH_DRIVER_H
virNWFilterTechDriverPtr virNWFilterTechDriverForName(const char *name);
--
1.7.0.3.448.g82eeb
2
2
Jiri Denemark (3):
cpuUpdate() for updating guest CPU according to host CPU
Helper function for making a deep-copy of virCPUDefPtr
Introduce UPDATE_CPU flag for virDomainGetXMLDesc
include/libvirt/libvirt.h.in | 5 +-
src/conf/cpu_conf.c | 37 ++++++++++
src/conf/cpu_conf.h | 3 +
src/cpu/cpu.c | 22 ++++++
src/cpu/cpu.h | 9 +++
src/cpu/cpu_generic.c | 1 +
src/cpu/cpu_x86.c | 161 +++++++++++++++++++++++++++++++++++++-----
src/libvirt.c | 3 +-
src/libvirt_private.syms | 2 +
src/qemu/qemu_driver.c | 54 ++++++++++++--
tools/virsh.c | 4 +
11 files changed, 273 insertions(+), 28 deletions(-)
3
11
[libvirt] [PATCH] Don't replace persistent domain config with migrated config
by Jiri Denemark 26 Mar '10
by Jiri Denemark 26 Mar '10
26 Mar '10
When a domain is defined on host1, migrated to host2 and then migrated
back to host1, its current configuration would overwrite the libvirtd's
in-memory copy of persistent configuration of that domain. This is not
desired as we want to preserve the persistent configuration untouched.
This patch introduces new 'live' parameter to virDomainAssignDef.
Passing 'true' for 'live' means the configuration passed to
virDomainAssignDef describes a configuration of live instance of the
domain. This applies for saved domains which are being restored or for
incoming domains during migration.
All callers have been changed to pass the appropriate value.
---
src/conf/domain_conf.c | 19 +++++++++++++------
src/conf/domain_conf.h | 5 ++++-
src/lxc/lxc_driver.c | 4 ++--
src/opennebula/one_driver.c | 4 ++--
src/openvz/openvz_driver.c | 4 ++--
src/qemu/qemu_driver.c | 10 +++++-----
src/test/test_driver.c | 10 +++++-----
src/uml/uml_driver.c | 4 ++--
8 files changed, 35 insertions(+), 25 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 22e1679..4cc27ff 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -749,18 +749,25 @@ static virDomainObjPtr virDomainObjNew(virCapsPtr caps)
virDomainObjPtr virDomainAssignDef(virCapsPtr caps,
virDomainObjListPtr doms,
- const virDomainDefPtr def)
+ const virDomainDefPtr def,
+ bool live)
{
virDomainObjPtr domain;
char uuidstr[VIR_UUID_STRING_BUFLEN];
if ((domain = virDomainFindByUUID(doms, def->uuid))) {
if (!virDomainObjIsActive(domain)) {
- virDomainDefFree(domain->def);
- domain->def = def;
+ if (live) {
+ /* save current configuration to be restored on domain shutdown */
+ if (!domain->newDef)
+ domain->newDef = domain->def;
+ domain->def = def;
+ } else {
+ virDomainDefFree(domain->def);
+ domain->def = def;
+ }
} else {
- if (domain->newDef)
- virDomainDefFree(domain->newDef);
+ virDomainDefFree(domain->newDef);
domain->newDef = def;
}
@@ -5780,7 +5787,7 @@ virDomainObjPtr virDomainLoadConfig(virCapsPtr caps,
newVM = 0;
}
- if (!(dom = virDomainAssignDef(caps, doms, def)))
+ if (!(dom = virDomainAssignDef(caps, doms, def, false)))
goto error;
dom->autostart = autostart;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 44fff0c..9e6cb69 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -810,9 +810,12 @@ void virDomainObjRef(virDomainObjPtr vm);
/* Returns 1 if the object was freed, 0 if more refs exist */
int virDomainObjUnref(virDomainObjPtr vm);
+/* live == true means def describes an active domain (being migrated or
+ * restored) as opposed to a new persistent configuration of the domain */
virDomainObjPtr virDomainAssignDef(virCapsPtr caps,
virDomainObjListPtr doms,
- const virDomainDefPtr def);
+ const virDomainDefPtr def,
+ bool live);
void virDomainRemoveInactive(virDomainObjListPtr doms,
virDomainObjPtr dom);
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index ba13065..9786cc0 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -381,7 +381,7 @@ static virDomainPtr lxcDomainDefine(virConnectPtr conn, const char *xml)
}
if (!(vm = virDomainAssignDef(driver->caps,
- &driver->domains, def)))
+ &driver->domains, def, false)))
goto cleanup;
def = NULL;
vm->persistent = 1;
@@ -1368,7 +1368,7 @@ lxcDomainCreateAndStart(virConnectPtr conn,
if (!(vm = virDomainAssignDef(driver->caps,
- &driver->domains, def)))
+ &driver->domains, def, false)))
goto cleanup;
def = NULL;
diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c
index e1d1efc..f7fbd46 100644
--- a/src/opennebula/one_driver.c
+++ b/src/opennebula/one_driver.c
@@ -251,7 +251,7 @@ static virDomainPtr oneDomainDefine(virConnectPtr conn, const char *xml)
goto return_point;
if (!(vm = virDomainAssignDef(driver->caps,
- &driver->domains, def))) {
+ &driver->domains, def, false))) {
virDomainDefFree(def);
goto return_point;
}
@@ -456,7 +456,7 @@ oneDomainCreateAndStart(virConnectPtr conn,
}
if (!(vm = virDomainAssignDef(driver->caps,
- &driver->domains, def))) {
+ &driver->domains, def, false))) {
virDomainDefFree(def);
goto return_point;
}
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 50aadfc..e0a0768 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -825,7 +825,7 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml)
goto cleanup;
}
if (!(vm = virDomainAssignDef(driver->caps,
- &driver->domains, vmdef)))
+ &driver->domains, vmdef, false)))
goto cleanup;
vmdef = NULL;
vm->persistent = 1;
@@ -905,7 +905,7 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
goto cleanup;
}
if (!(vm = virDomainAssignDef(driver->caps,
- &driver->domains, vmdef)))
+ &driver->domains, vmdef, false)))
goto cleanup;
vmdef = NULL;
/* All OpenVZ domains seem to be persistent - this is a bit of a violation
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 257f914..2c81d68 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3563,7 +3563,7 @@ static virDomainPtr qemudDomainCreate(virConnectPtr conn, const char *xml,
if (!(vm = virDomainAssignDef(driver->caps,
&driver->domains,
- def)))
+ def, false)))
goto cleanup;
def = NULL;
@@ -5220,7 +5220,7 @@ static int qemudDomainRestore(virConnectPtr conn,
if (!(vm = virDomainAssignDef(driver->caps,
&driver->domains,
- def))) {
+ def, true))) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("failed to assign new VM"));
goto cleanup;
@@ -5761,7 +5761,7 @@ static virDomainPtr qemudDomainDefine(virConnectPtr conn, const char *xml) {
if (!(vm = virDomainAssignDef(driver->caps,
&driver->domains,
- def))) {
+ def, false))) {
goto cleanup;
}
def = NULL;
@@ -8391,7 +8391,7 @@ qemudDomainMigratePrepareTunnel(virConnectPtr dconn,
if (!(vm = virDomainAssignDef(driver->caps,
&driver->domains,
- def))) {
+ def, true))) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("failed to assign new VM"));
goto cleanup;
@@ -8622,7 +8622,7 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
if (!(vm = virDomainAssignDef(driver->caps,
&driver->domains,
- def))) {
+ def, true))) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("failed to assign new VM"));
goto cleanup;
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index f54ebae..9a880f1 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -554,7 +554,7 @@ static int testOpenDefault(virConnectPtr conn) {
if (testDomainGenerateIfnames(conn, domdef) < 0)
goto error;
if (!(domobj = virDomainAssignDef(privconn->caps,
- &privconn->domains, domdef)))
+ &privconn->domains, domdef, false)))
goto error;
domdef = NULL;
@@ -910,7 +910,7 @@ static int testOpenFromFile(virConnectPtr conn,
if (testDomainGenerateIfnames(conn, def) < 0 ||
!(dom = virDomainAssignDef(privconn->caps,
- &privconn->domains, def))) {
+ &privconn->domains, def, false))) {
virDomainDefFree(def);
goto error;
}
@@ -1308,7 +1308,7 @@ testDomainCreateXML(virConnectPtr conn, const char *xml,
if (testDomainGenerateIfnames(conn, def) < 0)
goto cleanup;
if (!(dom = virDomainAssignDef(privconn->caps,
- &privconn->domains, def)))
+ &privconn->domains, def, false)))
goto cleanup;
def = NULL;
@@ -1853,7 +1853,7 @@ static int testDomainRestore(virConnectPtr conn,
if (testDomainGenerateIfnames(conn, def) < 0)
goto cleanup;
if (!(dom = virDomainAssignDef(privconn->caps,
- &privconn->domains, def)))
+ &privconn->domains, def, true)))
goto cleanup;
def = NULL;
@@ -2302,7 +2302,7 @@ static virDomainPtr testDomainDefineXML(virConnectPtr conn,
if (testDomainGenerateIfnames(conn, def) < 0)
goto cleanup;
if (!(dom = virDomainAssignDef(privconn->caps,
- &privconn->domains, def)))
+ &privconn->domains, def, false)))
goto cleanup;
def = NULL;
dom->persistent = 1;
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index bf06787..0c12469 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -1283,7 +1283,7 @@ static virDomainPtr umlDomainCreate(virConnectPtr conn, const char *xml,
if (!(vm = virDomainAssignDef(driver->caps,
&driver->domains,
- def)))
+ def, false)))
goto cleanup;
def = NULL;
@@ -1619,7 +1619,7 @@ static virDomainPtr umlDomainDefine(virConnectPtr conn, const char *xml) {
if (!(vm = virDomainAssignDef(driver->caps,
&driver->domains,
- def)))
+ def, false)))
goto cleanup;
def = NULL;
vm->persistent = 1;
--
1.7.0.3
3
5
Here's a revised patch for disk error policy XML incorporating the feedback from Dan and Daniel.
Dave
David Allan (1):
Add disk error policy to domain XML
docs/schemas/domain.rng | 12 +++++++-
src/conf/domain_conf.c | 18 +++++++++++
src/conf/domain_conf.h | 10 ++++++
src/libvirt_private.syms | 2 +-
src/qemu/qemu_conf.c | 17 +++++++++-
tests/qemuargv2xmltest.c | 3 ++
.../qemuxml2argv-disk-drive-error-policy-stop.args | 1 +
.../qemuxml2argv-disk-drive-error-policy-stop.xml | 32 ++++++++++++++++++++
tests/qemuxml2argvtest.c | 3 ++
9 files changed, 94 insertions(+), 4 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-stop.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-stop.xml
3
3
I pushed this trivial patch to fix a build break earlier today.
Dave
2
1
To find out where the net type 'direct' needs to be handled I introduced
the 'enum virDomainNetType' in the virDomainNetDef structure and let the
compiler tell me where the case statement is missing. Then I added the
unhandled device statement to the UML driver.
Signed-off-by; Stefan Berger <stefanb(a)us.ibm.com>
Index: libvirt-plain/src/conf/domain_conf.h
===================================================================
--- libvirt-plain.orig/src/conf/domain_conf.h
+++ libvirt-plain/src/conf/domain_conf.h
@@ -251,7 +251,7 @@ enum virDomainNetdevMacvtapType {
typedef struct _virDomainNetDef virDomainNetDef;
typedef virDomainNetDef *virDomainNetDefPtr;
struct _virDomainNetDef {
- int type;
+ enum virDomainNetType type;
unsigned char mac[VIR_MAC_BUFLEN];
char *model;
union {
Index: libvirt-plain/src/lxc/lxc_driver.c
===================================================================
--- libvirt-plain.orig/src/lxc/lxc_driver.c
+++ libvirt-plain/src/lxc/lxc_driver.c
@@ -800,6 +800,16 @@ static int lxcSetupInterfaces(virConnect
case VIR_DOMAIN_NET_TYPE_BRIDGE:
bridge = def->nets[i]->data.bridge.brname;
break;
+
+ case VIR_DOMAIN_NET_TYPE_USER:
+ case VIR_DOMAIN_NET_TYPE_ETHERNET:
+ case VIR_DOMAIN_NET_TYPE_SERVER:
+ case VIR_DOMAIN_NET_TYPE_CLIENT:
+ case VIR_DOMAIN_NET_TYPE_MCAST:
+ case VIR_DOMAIN_NET_TYPE_INTERNAL:
+ case VIR_DOMAIN_NET_TYPE_DIRECT:
+ case VIR_DOMAIN_NET_TYPE_LAST:
+ break;
}
DEBUG("bridge: %s", bridge);
Index: libvirt-plain/src/qemu/qemu_conf.c
===================================================================
--- libvirt-plain.orig/src/qemu/qemu_conf.c
+++ libvirt-plain/src/qemu/qemu_conf.c
@@ -2686,6 +2686,14 @@ qemuBuildHostNetStr(virDomainNetDefPtr n
net->data.socket.address,
net->data.socket.port);
break;
+ case VIR_DOMAIN_NET_TYPE_USER:
+ case VIR_DOMAIN_NET_TYPE_ETHERNET:
+ case VIR_DOMAIN_NET_TYPE_NETWORK:
+ case VIR_DOMAIN_NET_TYPE_BRIDGE:
+ case VIR_DOMAIN_NET_TYPE_INTERNAL:
+ case VIR_DOMAIN_NET_TYPE_DIRECT:
+ case VIR_DOMAIN_NET_TYPE_LAST:
+ break;
}
type_sep = ',';
break;
Index: libvirt-plain/src/uml/uml_conf.c
===================================================================
--- libvirt-plain.orig/src/uml/uml_conf.c
+++ libvirt-plain/src/uml/uml_conf.c
@@ -244,6 +244,14 @@ umlBuildCommandLineNet(virConnectPtr con
umlReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
_("internal networking type not supported"));
goto error;
+
+ case VIR_DOMAIN_NET_TYPE_DIRECT:
+ umlReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
+ _("direct networking type not supported"));
+ goto error;
+
+ case VIR_DOMAIN_NET_TYPE_LAST:
+ break;
}
virBufferVSprintf(&buf, ",%02x:%02x:%02x:%02x:%02x:%02x",
Index: libvirt-plain/src/conf/domain_conf.c
===================================================================
--- libvirt-plain.orig/src/conf/domain_conf.c
+++ libvirt-plain/src/conf/domain_conf.c
@@ -450,6 +450,10 @@ void virDomainNetDefFree(virDomainNetDef
case VIR_DOMAIN_NET_TYPE_DIRECT:
VIR_FREE(def->data.direct.linkdev);
break;
+
+ case VIR_DOMAIN_NET_TYPE_USER:
+ case VIR_DOMAIN_NET_TYPE_LAST:
+ break;
}
VIR_FREE(def->ifname);
@@ -1740,7 +1744,7 @@ virDomainNetDefParseXML(virCapsPtr caps,
type = virXMLPropString(node, "type");
if (type != NULL) {
- if ((def->type = virDomainNetTypeFromString(type)) < 0) {
+ if ((int)(def->type = virDomainNetTypeFromString(type)) < 0) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown interface type '%s'"), type);
goto error;
@@ -1949,6 +1953,10 @@ virDomainNetDefParseXML(virCapsPtr caps,
dev = NULL;
break;
+
+ case VIR_DOMAIN_NET_TYPE_USER:
+ case VIR_DOMAIN_NET_TYPE_LAST:
+ break;
}
if (ifname != NULL) {
@@ -4861,6 +4869,10 @@ virDomainNetDefFormat(virBufferPtr buf,
virDomainNetdevMacvtapTypeToString(def->data.direct.mode));
virBufferAddLit(buf, "/>\n");
break;
+
+ case VIR_DOMAIN_NET_TYPE_USER:
+ case VIR_DOMAIN_NET_TYPE_LAST:
+ break;
}
if (def->ifname)
2
1
Re: [libvirt] [Qemu-devel] Re: Supporting hypervisor specific APIs in libvirt
by Anthony Liguori 26 Mar '10
by Anthony Liguori 26 Mar '10
26 Mar '10
On 03/23/2010 10:57 AM, Paul Brook wrote:
>>> I think there is a serious divergence of approach there, instanciating
>>> API stating 'we are gonna deprecate them sooner or later' tell the
>>> application developper 'my time is more important than yours' and not
>>> really something I like to carry to the API users.
>>> The main goal of libvirt remains to provide APIs needed to unify the
>>> development of the virtualization layers. Having APIs which makes
>>> sense only for one or 2 virtualization engines is not a problem in
>>> itself, it just raises questions about the actual semantic of that API.
>>> If that semantic is sound, then I see no reason to not add it, really
>>> and we actually often do.
>>>
>> Yeah, but the problem we're facing is, I want there to be an API added
>> to the management layer as part of the feature commit in qemu. If there
>> has to be a discussion and decisions about how to model the API, it's
>> not going to be successful.
>>
> I thought the monitor protocol *was* our API. If not, why not?
>
It is. But our API is missing key components like guest enumeration.
So the fundamental topic here is, do we introduce these missing
components to allow people to build directly to our interface or do we
make use of the functionality that libvirt already provides if they can
plumb our API directly to users.
Regards,
Anthony Liguori
> Paul
>
10
65
26 Mar '10
In the web documentation mention that the direct device support is there
since libvirt 0.7.7. A Linux kernel 2.6.34 is required for macvtap to be
available as standard device.
Index: libvirt-plain/docs/formatdomain.html.in
===================================================================
--- libvirt-plain.orig/docs/formatdomain.html.in
+++ libvirt-plain/docs/formatdomain.html.in
@@ -741,8 +741,11 @@
<p>
Provides direct attachment of the virtual machine's NIC to the given
- physial interface of the host. This setup requires the Linux macvtap
- driver to be available. One of the modes 'vepa'
+ physial interface of the host.
+ <span class="since">Since 0.7.7 (QEMU and KVM only)</span><br>
+ This setup requires the Linux macvtap
+ driver to be available. <span class="since">(Since Linux 2.6.34.)</span>
+ One of the modes 'vepa'
( <a href="http://www.ieee802.org/1/files/public/docs2009/new-evb-congdon-vepa-modular…">
'Virtual Ethernet Port Aggregator'</a>), 'bridge' or 'private'
can be chosen for the operation mode of the macvtap device, 'vepa'
2
1
[libvirt] [PATCH] Fix QEMU cpu affinity at startup to include all threads
by Daniel P. Berrange 26 Mar '10
by Daniel P. Berrange 26 Mar '10
26 Mar '10
The QEMU cpu affinity is used in NUMA scenarios to ensure that
guest memory is allocated from a specific node. Normally memory
is allocate on demand in vCPU threads, but when using hugepages
the initial thread leader allocates memory upfront. libvirt was
not setting affinity of the thread leader, or I/O threads. This
patch changes the code to set the process affinity in between
the fork()/exec() of QEMU. This ensures that every single QEMU
thread gets the affinity
* src/qemu/qemu_driver.c: Set affinity on entire QEMU process
at startup
---
src/qemu/qemu_driver.c | 29 ++++++++++++++++-------------
1 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 257f914..2598deb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1701,6 +1701,9 @@ qemuDetectVcpuPIDs(struct qemud_driver *driver,
return 0;
}
+/*
+ * To be run between fork/exec of QEMU only
+ */
static int
qemudInitCpuAffinity(virDomainObjPtr vm)
{
@@ -1708,7 +1711,8 @@ qemudInitCpuAffinity(virDomainObjPtr vm)
virNodeInfo nodeinfo;
unsigned char *cpumap;
int cpumaplen;
- qemuDomainObjPrivatePtr priv = vm->privateData;
+
+ DEBUG0("Setting CPU affinity");
if (nodeGetInfo(NULL, &nodeinfo) < 0)
return -1;
@@ -1740,14 +1744,14 @@ qemudInitCpuAffinity(virDomainObjPtr vm)
VIR_USE_CPU(cpumap, i);
}
- /* The XML config only gives a per-VM affinity, so we apply
- * the same mapping to all vCPUs */
- for (i = 0 ; i < priv->nvcpupids ; i++) {
- if (virProcessInfoSetAffinity(priv->vcpupids[i],
- cpumap, cpumaplen, maxcpu) < 0) {
- VIR_FREE(cpumap);
- return -1;
- }
+ /* We are assuming we are running between fork/exec of QEMU, so
+ * that getpid() gives the QEMU process ID and we know that
+ * no threads are running.
+ */
+ if (virProcessInfoSetAffinity(getpid(),
+ cpumap, cpumaplen, maxcpu) < 0) {
+ VIR_FREE(cpumap);
+ return -1;
}
VIR_FREE(cpumap);
@@ -2653,6 +2657,9 @@ struct qemudHookData {
static int qemudSecurityHook(void *data) {
struct qemudHookData *h = data;
+ if (qemudInitCpuAffinity(h->vm) < 0)
+ return -1;
+
if (qemuAddToCgroup(h->driver, h->vm->def) < 0)
return -1;
@@ -2943,10 +2950,6 @@ static int qemudStartVMDaemon(virConnectPtr conn,
if (qemuDetectVcpuPIDs(driver, vm) < 0)
goto abort;
- DEBUG0("Setting CPU affinity");
- if (qemudInitCpuAffinity(vm) < 0)
- goto abort;
-
DEBUG0("Setting any required VM passwords");
if (qemuInitPasswords(conn, driver, vm, qemuCmdFlags) < 0)
goto abort;
--
1.6.2.5
2
1
[libvirt] [PATCH][Network] Make dhcp service enabled only if //ip/dhcp exists in network xml
by Satoru SATOH 26 Mar '10
by Satoru SATOH 26 Mar '10
26 Mar '10
Libvirtd enabls DHCP service on virtual networks even if the element
'//ip/dhcp' does not exist in the network xml. The following patch fixes
this problem.
Signed-off-by: Satoru SATOH <satoru.satoh(a)gmail.com>
---
src/conf/network_conf.c | 2 ++
src/conf/network_conf.h | 2 ++
src/network/bridge_driver.c | 5 +----
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 1f3a44c..e41775a 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -466,6 +466,8 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
if ((ip = virXPathNode("./ip[1]", ctxt)) &&
virNetworkIPParseXML(def, ip) < 0)
goto error;
+
+ def->dhcp = (virXPathNode("./ip/dhcp", ctxt) != NULL ? 1 : 0);
}
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index 127a23a..847ddd3 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -74,6 +74,8 @@ struct _virNetworkDef {
char *netmask;
char *network;
+ unsigned int dhcp;
+
unsigned int nranges; /* Zero or more dhcp ranges */
virNetworkDHCPRangeDefPtr ranges;
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 83ab00e..6dcf7b4 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -943,12 +943,9 @@ static int networkStartNetworkDaemon(struct network_driver *driver,
goto err_delbr2;
}
- if ((network->def->ipAddress ||
- network->def->nranges) &&
- dhcpStartDhcpDaemon(network) < 0)
+ if (network->def->dhcp && dhcpStartDhcpDaemon(network) < 0)
goto err_delbr2;
-
/* Persist the live configuration now we have bridge info */
if (virNetworkSaveConfig(NETWORK_STATE_DIR, network->def) < 0) {
goto err_kill;
--
1.6.2.5
2
2
[libvirt] [PATCH 1/1] XenAPI remote storage support on libvirt
by Sharadha Prabhakar (3P) 26 Mar '10
by Sharadha Prabhakar (3P) 26 Mar '10
26 Mar '10
This patch contains the APIs for support XenAPI remote storage support on libvirt.
This patch allows you to list storage pools, storage volumes, get information
about storage pools and volumes and create storage pools of type NETFS
with format type nfs,cifs-iso,nfs-iso using virsh. You can also create
VMs with storage pools attached and destroy storage pools.
While creating a VM with storage. The disk tag's source element should be
of the form '/storage pool uuid/storage volume uuid'.
--- ./libvirt_org/src/xenapi/xenapi_storage_driver.c 1970-01-01 01:00:00.000000000 +0100
+++ ./libvirt/src/xenapi/xenapi_storage_driver.c 2010-03-24 15:27:43.000000000 +0000
@@ -0,0 +1,1499 @@
+/*
+ * xenapi_storage_driver.c: Xen API storage driver APIs
+ * Copyright (C) 2009, 2010 Citrix Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Sharadha Prabhakar <sharadha.prabhakar(a)citrix.com>
+ */
+
+#include <config.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <libxml/uri.h>
+#include <xen_internal.h>
+#include <libxml/parser.h>
+#include <curl/curl.h>
+#include <xen/api/xen_common.h>
+#include <xen/api/xen_vm.h>
+#include <xen/api/xen_vm.h>
+#include <xen/api/xen_all.h>
+#include <xen/api/xen_vm_metrics.h>
+#include <xen/api/xen_api_failure.h>
+#include <xen/dom0_ops.h>
+
+#include "libvirt_internal.h"
+#include "libvirt/libvirt.h"
+#include "virterror_internal.h"
+#include "storage_conf.h"
+#include "datatypes.h"
+#include "xenapi_driver.h"
+#include "util.h"
+#include "uuid.h"
+#include "authhelper.h"
+#include "memory.h"
+#include "driver.h"
+#include "util/logging.h"
+#include "buf.h"
+#include "xenapi_utils.h"
+#include "xenapi_storage_driver.h"
+
+/*
+*XenapiStorageOpen
+*
+*Authenticates and creates a session with the server
+*Returns VIR_DRV_OPEN_SUCCESS on success, else VIR_DRV_OPEN_ERROR
+*/
+static virDrvOpenStatus
+xenapiStorageOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
+{
+ char *username = NULL;
+ char *password = NULL;
+ struct _xenapiStoragePrivate *privP = NULL;
+
+ if (conn->uri == NULL || conn->uri->scheme == NULL ||
+ STRCASENEQ(conn->uri->scheme, "XenAPI")) {
+ return VIR_DRV_OPEN_DECLINED;
+ }
+
+ if (conn->uri->server == NULL) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED,
+ "Server name not in URI");
+ goto error;
+ }
+
+ if (auth == NULL) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED,
+ "Authentication Credentials not found");
+ goto error;
+ }
+
+ if (conn->uri->user != NULL) {
+ username = strdup(conn->uri->user);
+
+ if (username == NULL) {
+ virReportOOMError();
+ goto error;
+ }
+ } else {
+ username = virRequestUsername(auth, NULL, conn->uri->server);
+
+ if (username == NULL) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED,
+ "Username request failed");
+ goto error;
+ }
+ }
+
+ password = virRequestPassword(auth, username, conn->uri->server);
+
+ if (password == NULL) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED,
+ "Password request failed");
+ goto error;
+ }
+
+ if (VIR_ALLOC(privP) < 0) {
+ virReportOOMError();
+ goto error;
+ }
+
+ if (virAsprintf(&privP->url, "https://%s", conn->uri->server) < 0) {
+ virReportOOMError();
+ goto error;
+ }
+
+ if (xenapiUtil_ParseQuery(conn, conn->uri, &privP->noVerify) < 0)
+ goto error;
+
+ xmlInitParser();
+ xmlKeepBlanksDefault(0);
+ xen_init();
+ curl_global_init(CURL_GLOBAL_ALL);
+
+ privP->session = xen_session_login_with_password(call_func, privP, username,
+ password, xen_api_latest_version);
+
+ if (privP->session != NULL && privP->session->ok) {
+ conn->storagePrivateData = privP;
+ VIR_FREE(username);
+ VIR_FREE(password);
+ return VIR_DRV_OPEN_SUCCESS;
+ }
+
+ xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED, "");
+
+ error:
+ VIR_FREE(username);
+ VIR_FREE(password);
+
+ if (privP != NULL) {
+ if (privP->session != NULL)
+ xenSessionFree(privP->session);
+
+ VIR_FREE(privP->url);
+ VIR_FREE(privP);
+ }
+
+ return VIR_DRV_OPEN_ERROR;
+}
+
+
+/*
+*XenapiStorageClose
+*
+*Closes the session with the server
+*Returns 0 on success
+*/
+static int
+xenapiStorageClose (virConnectPtr conn)
+{
+ struct _xenapiStoragePrivate *priv = (struct _xenapiStoragePrivate *)conn->storagePrivateData;
+ xen_session_logout(priv->session);
+ VIR_FREE(priv->url);
+ VIR_FREE(priv);
+ return 0;
+
+}
+
+/*
+*XenapiNumOfStoragePools
+*
+*Provides the number of active storage pools
+*Returns number of pools found on success, or -1 on error
+*/
+static int
+xenapiNumOfStoragePools (virConnectPtr conn)
+{
+ xen_sr_set *sr_set=NULL;
+ xen_pbd_set *pbd_set=NULL;
+ xen_sr_record *record=NULL;
+ bool currently_attached;
+ int cnt=-1,i;
+ xen_session * session = ((struct _xenapiStoragePrivate *)(conn->storagePrivateData))->session;
+ if (xen_sr_get_all(session, &sr_set) && sr_set->size>0) {
+ for (i=0; i<sr_set->size; i++) {
+ if (xen_sr_get_record(session, &record, sr_set->contents[i])) {
+ if (xen_sr_get_pbds(session, &pbd_set, sr_set->contents[i]) && pbd_set->size>0) {
+ xen_pbd_get_currently_attached(session, ¤tly_attached, pbd_set->contents[0]);
+ if (currently_attached == 1) cnt++;
+ xen_pbd_set_free(pbd_set);
+ } else {
+ if (pbd_set) {
+ xen_pbd_set_free(pbd_set);
+ xen_sr_record_free(record);
+ xen_sr_set_free(sr_set);
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Physical Block Devices not found");
+ return -1;
+ }
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ xen_sr_record_free(record);
+ xen_sr_set_free(sr_set);
+ return -1;
+ }
+ xen_sr_record_free(record);
+ } else {
+ xen_sr_set_free(sr_set);
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ return -1;
+ }
+ }
+ xen_sr_set_free(sr_set);
+ } else {
+ if (sr_set) {
+ xen_sr_set_free(sr_set);
+ xenapiSessionErrorHandler(conn, VIR_ERR_NO_STORAGE_POOL, "");
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ }
+ return cnt;
+}
+
+/*
+*XenapiListStoragePools
+*
+*Provides the list of names of active storage pools upto maxnames
+*returns number of names in the list on success ,or -1 or error
+*/
+static int
+xenapiListStoragePools (virConnectPtr conn, char **const names,
+ int maxnames)
+{
+ xen_sr_set *sr_set=NULL;
+ xen_pbd_set *pbd_set=NULL;
+ xen_sr_record *record=NULL;
+ char *usenames=NULL;
+ bool currently_attached;
+ int count=0,i;
+ xen_session * session = ((struct _xenapiStoragePrivate *)(conn->storagePrivateData))->session;
+ if (xen_sr_get_all(session, &sr_set) && sr_set->size>0) {
+ for (i=0; (i<sr_set->size) && (count<maxnames); i++) {
+ if (xen_sr_get_record(session, &record, sr_set->contents[i])) {
+ if (xen_sr_get_pbds(session, &pbd_set, sr_set->contents[i]) && pbd_set->size>0) {
+ xen_pbd_get_currently_attached(session, ¤tly_attached, pbd_set->contents[0]);
+ if (currently_attached == 1) {
+ if(!(usenames = strdup(record->name_label))) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ names[count++] = usenames;
+ }
+ xen_pbd_set_free(pbd_set);
+ } else {
+ if (pbd_set) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Physical Block Devices not found");
+ goto cleanup;
+ }
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ xen_sr_record_free(record);
+ xen_sr_set_free(sr_set);
+ return -1;
+ }
+ xen_sr_record_free(record);
+ } else {
+ xen_sr_set_free(sr_set);
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ return -1;
+ }
+ }
+ xen_sr_set_free(sr_set);
+ return count;
+ } else {
+ if (sr_set) {
+ xen_sr_set_free(sr_set);
+ xenapiSessionErrorHandler(conn, VIR_ERR_NO_STORAGE_POOL, "");
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ }
+ return -1;
+ cleanup:
+ xen_pbd_set_free(pbd_set);
+ xen_sr_record_free(record);
+ xen_sr_set_free(sr_set);
+ while (--count>=0) VIR_FREE(names[count]);
+ return -1;
+}
+
+
+/*
+*XenapiListDefinedStoragePools
+*
+*Provides the list of names of inactive storage pools upto maxnames
+*
+*/
+static int
+xenapiListDefinedStoragePools (virConnectPtr conn, char **const names,
+ int maxnames)
+{
+ xen_sr_set *sr_set=NULL;
+ xen_pbd_set *pbd_set=NULL;
+ xen_sr_record *record=NULL;
+ char *usenames=NULL;
+ bool currently_attached;
+ int count=0,i;
+ xen_session * session = ((struct _xenapiStoragePrivate *)(conn->storagePrivateData))->session;
+ if (xen_sr_get_all(session, &sr_set) && sr_set->size>0) {
+ for (i=0; (i<sr_set->size) && (count<maxnames); i++) {
+ if (xen_sr_get_record(session, &record, sr_set->contents[i])) {
+ if (xen_sr_get_pbds(session, &pbd_set, sr_set->contents[i]) && pbd_set->size>0) {
+ xen_pbd_get_currently_attached(session, ¤tly_attached, pbd_set->contents[0]);
+ if (currently_attached == 0) {
+ if(!(usenames = strdup(record->name_label))) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ names[count++] = usenames;
+ }
+ xen_pbd_set_free(pbd_set);
+ } else {
+ if (pbd_set) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Physical Block Devices not found");
+ goto cleanup;
+ }
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ xen_sr_record_free(record);
+ xen_sr_set_free(sr_set);
+ return -1;
+ }
+ xen_sr_record_free(record);
+ } else {
+ xen_sr_set_free(sr_set);
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ return -1;
+ }
+ }
+ xen_sr_set_free(sr_set);
+ return count;
+ } else {
+ if (sr_set) {
+ xen_sr_set_free(sr_set);
+ xenapiSessionErrorHandler(conn, VIR_ERR_NO_STORAGE_POOL, "");
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ }
+ return -1;
+
+ cleanup:
+ xen_pbd_set_free(pbd_set);
+ xen_sr_record_free(record);
+ xen_sr_set_free(sr_set);
+ while (--count>=0) free(names[count]);
+ return -1;
+}
+
+
+/*
+*XenapiNumOfDefinedStoragePools
+*
+*Provides the number of inactive storage pools
+*
+*/
+static int
+xenapiNumOfDefinedStoragePools (virConnectPtr conn)
+{
+ xen_sr_set *sr_set=NULL;
+ xen_pbd_set *pbd_set=NULL;
+ xen_sr_record *record=NULL;
+ int cnt=-1,i;
+ xen_session * session = ((struct _xenapiStoragePrivate *)(conn->storagePrivateData))->session;
+ if (xen_sr_get_all(session, &sr_set) && sr_set->size>0) {
+ for (i=0; i<sr_set->size; i++) {
+ if (xen_sr_get_record(session, &record, sr_set->contents[i])) {
+ if (xen_sr_get_pbds(session, &pbd_set, sr_set->contents[i]) && pbd_set->size>0) {
+ bool currently_attached;
+ xen_pbd_get_currently_attached(session, ¤tly_attached, pbd_set->contents[0]);
+ if (currently_attached == 0) cnt++;
+ xen_pbd_set_free(pbd_set);
+ } else {
+ if (pbd_set) {
+ xen_pbd_set_free(pbd_set);
+ xen_sr_record_free(record);
+ xen_sr_set_free(sr_set);
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Physical Block Devices not found");
+ return -1;
+ }
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ xen_sr_record_free(record);
+ xen_sr_set_free(sr_set);
+ return -1;
+ }
+ xen_sr_record_free(record);
+ } else {
+ xen_sr_set_free(sr_set);
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ return -1;
+ }
+ }
+ xen_sr_set_free(sr_set);
+ } else {
+ if (sr_set) {
+ xen_sr_set_free(sr_set);
+ xenapiSessionErrorHandler(conn, VIR_ERR_NO_STORAGE_POOL, "");
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ }
+ return cnt;
+}
+
+/*
+*XenapiStoragePoolCreateXML
+*
+*Creates a Storage Pool from the given XML
+* Only storage pool type NETFS is supported for now
+*/
+static virStoragePoolPtr
+xenapiStoragePoolCreateXML (virConnectPtr conn, const char *xmlDesc,
+ unsigned int flags ATTRIBUTE_UNUSED)
+{
+ virStoragePoolDefPtr pdef = NULL;
+ char *pooltype=NULL;
+ xen_sr sr=NULL;
+ xen_host host=NULL;
+ virBuffer path = VIR_BUFFER_INITIALIZER;
+ xen_string_string_map *device_config=NULL,*smconfig=NULL;
+ virStoragePoolPtr poolPtr = NULL;
+ unsigned char raw_uuid[VIR_UUID_BUFLEN];
+ xen_sr_record *sr_record = NULL;
+ xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
+ if(!(pdef = virStoragePoolDefParseString(xmlDesc))) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Couldn't parse XML");
+ virBufferFreeAndReset(&path);
+ return NULL;
+ }
+ if (pdef->type != VIR_STORAGE_POOL_NETFS) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Only Pool type NETFS is currently supported");
+ goto cleanup;
+ } else {
+ if (pdef->source.format == VIR_STORAGE_POOL_NETFS_NFS_ISO) {
+ pooltype = (char *)"iso";
+ if (!pdef->source.host.name) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Host name required for creating NFS ISO SR");
+ goto cleanup;
+ }
+ if (!pdef->source.dir) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Directory required for creating NFS ISO SR");
+ goto cleanup;
+ }
+ device_config = xen_string_string_map_alloc(1);
+ if (!(device_config->contents[0].key = strdup("location"))) {
+ goto cleanup_device_config;
+ }
+ virBufferVSprintf(&path,"%s:%s",pdef->source.host.name, pdef->source.dir);
+ device_config->contents[0].val = virBufferContentAndReset(&path);
+ smconfig = xen_string_string_map_alloc(0);
+ }
+ else if (pdef->source.format == VIR_STORAGE_POOL_NETFS_CIFS_ISO) {
+ pooltype = (char *)"iso";
+ if (!pdef->source.host.name) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Host name required for creating CIFS ISO SR");
+ goto cleanup;
+ }
+ if (!pdef->source.dir) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Directory required for creating CIFS ISO SR");
+ goto cleanup;
+ }
+ device_config = xen_string_string_map_alloc(1);
+ if (!(device_config->contents[0].key = strdup("location")))
+ goto cleanup_device_config;
+
+ if (pdef->source.host.name[0] != '/') {
+ virBufferVSprintf(&path,"//%s%s",pdef->source.host.name, pdef->source.dir);
+ }
+ else {
+ virBufferVSprintf(&path,"%s%s",pdef->source.host.name, pdef->source.dir);
+ }
+ device_config->contents[0].val = virBufferContentAndReset(&path);
+ smconfig = xen_string_string_map_alloc(1);
+ if (!(smconfig->contents[0].key = strdup("iso_type"))) {
+ xen_string_string_map_free(smconfig);
+ xen_string_string_map_free(device_config);
+ virStoragePoolDefFree(pdef);
+ return NULL;
+ }
+ if (!(smconfig->contents[0].val = strdup("cifs"))) {
+ xen_string_string_map_free(smconfig);
+ xen_string_string_map_free(device_config);
+ virStoragePoolDefFree(pdef);
+ return NULL;
+ }
+ }
+ else if (pdef->source.format == VIR_STORAGE_POOL_NETFS_NFS) {
+ pooltype = (char *)"nfs";
+ if (!pdef->source.host.name) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Server name required for creating NFS SR");
+ goto cleanup;
+ }
+ if (!pdef->source.dir) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Directory required for creating NFS SR");
+ goto cleanup;
+ }
+ device_config = xen_string_string_map_alloc(2);
+ if (!(device_config->contents[0].key = strdup("server")))
+ goto cleanup_device_config;
+ if (!(device_config->contents[0].val = strdup(pdef->source.host.name)))
+ goto cleanup_device_config;
+ if (!(device_config->contents[1].key = strdup("serverpath")))
+ goto cleanup_device_config;
+ if (!(device_config->contents[1].val = strdup(pdef->source.dir)))
+ goto cleanup_device_config;
+ smconfig = xen_string_string_map_alloc(0);
+ virBufferFreeAndReset(&path);
+ }
+ else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Format type of NETFS not supported by the hypervisor");
+ goto cleanup;
+ }
+ }
+ if (!xen_session_get_this_host(session, &host, session)) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ virStoragePoolDefFree(pdef);
+ return NULL;
+ }
+ if (!xen_sr_create(session, &sr, host, device_config, 0, pdef->name, (char *)"",
+ pooltype, (char *) "iso", true, smconfig)) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ virStoragePoolDefFree(pdef);
+ xen_host_free(host);
+ return NULL;
+ }
+ if (!xen_sr_get_record(session, &sr_record, sr)){
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ virStoragePoolDefFree(pdef);
+ xen_host_free(host);
+ xen_sr_free(sr);
+ return NULL;
+ }
+ virUUIDParse(sr_record->uuid,raw_uuid);
+ poolPtr = virGetStoragePool(conn,(const char *)sr_record->name_label,raw_uuid);
+ if (!poolPtr) xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Couldn't get a valid storage pool pointer");
+ virStoragePoolDefFree(pdef);
+ xen_sr_record_free(sr_record);
+ xen_host_free(host);
+ return poolPtr;
+
+ cleanup_device_config:
+ xen_string_string_map_free(device_config);
+
+ cleanup:
+ virStoragePoolDefFree(pdef);
+ virBufferFreeAndReset(&path);
+ return NULL;
+}
+
+static int
+xenapiStoragePoolBuild (virStoragePoolPtr pool ATTRIBUTE_UNUSED,
+ unsigned int flags ATTRIBUTE_UNUSED)
+{
+ return 0; /* return SUCCESS for now */
+}
+
+
+static int
+xenapiStoragePoolCreate (virStoragePoolPtr pool ATTRIBUTE_UNUSED,
+ unsigned int flags ATTRIBUTE_UNUSED)
+{
+ return 0;
+}
+
+
+/*
+*XenapiStoragePoolSetAutostart
+*
+*Autostart option is always ON by default and is not allowed to be OFF
+*
+*/
+static int
+xenapiStoragePoolSetAutostart (virStoragePoolPtr pool, int autostart)
+{
+ virConnectPtr conn = pool->conn;
+ if (autostart == 1) {
+ VIR_DEBUG0("XenAPI storage pools autostart option is always ON by default");
+ return 0;
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Hypervisor doesn't allow autostart to be OFF");
+ return -1;
+ }
+}
+
+
+/*
+*XenapiStoragePoolGetAutostart
+*
+*Returns the storage pool autostart option. Which is always ON
+*
+*/
+static int
+xenapiStoragePoolGetAutostart (virStoragePoolPtr pool ATTRIBUTE_UNUSED,
+ int * autostart)
+{
+ *autostart=1; /* XenAPI storage pools always have autostart set to ON */
+ return 0;
+}
+
+
+/*
+*XenapiStoragePoolLookupByName
+*
+* storage pool based on its unique name
+*
+*/
+static virStoragePoolPtr
+xenapiStoragePoolLookupByName (virConnectPtr conn,
+ const char * name)
+{
+ virStoragePoolPtr poolPtr=NULL;
+ xen_sr_record *record=NULL;
+ xen_sr_set *sr_set=NULL;
+ xen_sr sr=NULL;
+ unsigned char raw_uuid[VIR_UUID_BUFLEN];
+ xen_session *session = ((struct _xenapiStoragePrivate *)(conn->storagePrivateData))->session;
+ if (xen_sr_get_by_name_label(session, &sr_set, (char *)name) && sr_set->size>0) {
+ if (sr_set->size!=1) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Storage Pool name is not unique");
+ xen_sr_set_free(sr_set);
+ return NULL;
+ }
+ sr = sr_set->contents[0];
+ if (!xen_sr_get_record(session, &record, sr)) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ xen_sr_set_free(sr_set);
+ return NULL;
+ }
+ virUUIDParse(record->uuid,raw_uuid);
+ if (!(poolPtr = virGetStoragePool(conn,name,raw_uuid)))
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Storage Pool pointer not available");
+ xen_sr_record_free(record);
+ xen_sr_set_free(sr_set);
+ } else {
+ if (sr_set) {
+ xen_sr_set_free(sr_set);
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Storage Pool not found");
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ }
+ return poolPtr;
+}
+
+
+/*
+*XenapiStoragePoolGetXMLDesc
+*
+*Returns the configuration of a storage pool as XML
+*
+*/
+static char *
+xenapiStoragePoolGetXMLDesc (virStoragePoolPtr pool,
+ unsigned int flags ATTRIBUTE_UNUSED)
+{
+ xen_sr_record *record=NULL;
+ xen_sr sr=NULL;
+ xen_pbd_set *pbd_set=NULL;
+ xen_pbd pbd=NULL;
+ char *pathDetails = NULL, *host=NULL, *path=NULL,*xml=NULL;
+ virConnectPtr conn = pool->conn;
+ virStoragePoolDefPtr pdef=NULL;
+ xen_string_string_map *smconfig=NULL;
+ bool cifs;
+ xen_string_string_map *deviceConfig=NULL;
+ char uuidStr[VIR_UUID_STRING_BUFLEN];
+ int i;
+ xen_session *session = ((struct _xenapiStoragePrivate *)(conn->storagePrivateData))->session;
+ virUUIDFormat(pool->uuid,uuidStr);
+ if (xen_sr_get_by_uuid(session, &sr, uuidStr)) {
+ if (!xen_sr_get_record(session, &record, sr)) {
+ xen_sr_free(sr);
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Couldn't get SR information");
+ return NULL;
+ }
+ if (VIR_ALLOC(pdef)<0) {
+ virReportOOMError();
+ xen_sr_record_free(record);
+ return NULL;
+ }
+ if (STREQ(record->type,"nfs") || STREQ(record->type,"iso"))
+ pdef->type = VIR_STORAGE_POOL_NETFS;
+ else if(STREQ(record->type,"iscsi"))
+ pdef->type = VIR_STORAGE_POOL_ISCSI;
+ else if(STREQ(record->type,"file"))
+ pdef->type = VIR_STORAGE_POOL_DIR;
+ else if(STREQ(record->type,"lvm"))
+ pdef->type = VIR_STORAGE_POOL_LOGICAL;
+ else if(STREQ(record->type,"ext")) {
+ pdef->type = VIR_STORAGE_POOL_FS;
+ pdef->source.format = VIR_STORAGE_POOL_FS_EXT3;
+ }
+ else if(STREQ(record->type,"hba"))
+ pdef->type = VIR_STORAGE_POOL_SCSI;
+
+ if (!(pdef->name = strdup(record->name_label))) {
+ virReportOOMError();
+ xen_sr_record_free(record);
+ virStoragePoolDefFree(pdef);
+ return NULL;
+ }
+ virUUIDParse(record->uuid,pdef->uuid);
+ pdef->allocation = (record->virtual_allocation)/1024;
+ pdef->capacity = (record->physical_size)/1024;
+ pdef->available = (record->physical_size - record->physical_utilisation)/1024;
+
+ if (STREQ(record->type,"iso")) {
+ if (xen_sr_get_sm_config(session, &smconfig, sr)){
+ cifs = false;
+ for (i=0;i<smconfig->size;i++){
+ if (STREQ(smconfig->contents[i].key,"iso_type")
+ && STREQ(smconfig->contents[i].val, "cifs"))
+ cifs = true;
+ break;
+ }
+ xen_string_string_map_free(smconfig);
+ xen_sr_get_pbds (session, &pbd_set, sr);
+ pbd = pbd_set->contents[0];
+ xen_pbd_get_device_config(session, &deviceConfig, pbd);
+ if (deviceConfig) {
+ for (i=0;i<deviceConfig->size;i++) {
+ if(STREQ(deviceConfig->contents[i].key,"location")) {
+ if (!(pathDetails = strdup(deviceConfig->contents[i].val))) {
+ virReportOOMError();
+ xen_sr_record_free(record);
+ virStoragePoolDefFree(pdef);
+ xen_string_string_map_free(deviceConfig);
+ xen_pbd_set_free(pbd_set);
+ return NULL;
+ }
+ break;
+ }
+ }
+ xen_string_string_map_free(deviceConfig);
+ xen_pbd_set_free(pbd_set);
+ }
+ if (pathDetails) {
+ if (VIR_ALLOC_N(host,strlen(pathDetails)) <0) {
+ virReportOOMError();
+ xen_sr_record_free(record);
+ virStoragePoolDefFree(pdef);
+ VIR_FREE(pathDetails);
+ return NULL;
+ }
+ if (VIR_ALLOC_N(path,strlen(pathDetails)) <0) {
+ virReportOOMError();
+ xen_sr_record_free(record);
+ virStoragePoolDefFree(pdef);
+ VIR_FREE(host);
+ VIR_FREE(pathDetails);
+ return NULL;
+ }
+ host[0]='\0';path[0]='\0';
+ if (cifs) {
+ pdef->source.format = VIR_STORAGE_POOL_NETFS_CIFS_ISO;
+ sscanf(pathDetails,"//%[^/]%s",host,path);
+ } else {
+ pdef->source.format = VIR_STORAGE_POOL_NETFS_NFS_ISO;
+ sscanf(pathDetails,"%[^:]:%s",host,path);
+ }
+ if (STRNEQ(host,"\0")) {
+ if (!(pdef->source.host.name = strdup(host))) {
+ virReportOOMError();
+ xen_sr_record_free(record);
+ virStoragePoolDefFree(pdef);
+ VIR_FREE(host);
+ VIR_FREE(path);
+ VIR_FREE(pathDetails);
+ return NULL;
+ }
+ }
+ if (STRNEQ(path,"\0")) {
+ if (!(pdef->source.dir = strdup(path))) {
+ virReportOOMError();
+ xen_sr_record_free(record);
+ virStoragePoolDefFree(pdef);
+ VIR_FREE(host);
+ VIR_FREE(path);
+ VIR_FREE(pathDetails);
+ return NULL;
+ }
+ }
+ VIR_FREE(host);
+ VIR_FREE(path);
+ VIR_FREE(pathDetails);
+ }
+ }
+ }
+ if (!(pdef->target.path = strdup("/"))) {
+ virReportOOMError();
+ xen_sr_record_free(record);
+ virStoragePoolDefFree(pdef);
+ return NULL;
+ }
+ xen_sr_record_free(record);
+ xml = virStoragePoolDefFormat(pdef);
+ virStoragePoolDefFree(pdef);
+ if (!xml)
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Couldn't convert to XML format");
+ return xml;
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ return NULL;
+ }
+}
+
+
+/*
+*XenapiStoragePoolNumOfVolumes
+*
+*Fetch the number of storage volumes within a pool
+*
+*/
+static int
+xenapiStoragePoolNumOfVolumes (virStoragePoolPtr pool ATTRIBUTE_UNUSED)
+{
+ xen_sr_set *sr_set=NULL;
+ xen_sr sr=NULL;
+ xen_vdi_set *vdi_set=NULL;
+ virConnectPtr conn = pool->conn;
+ xen_session *session = ((struct _xenapiStoragePrivate *)(conn->storagePrivateData))->session;
+ int count=0;
+ if (xen_sr_get_by_name_label(session, &sr_set, pool->name) && sr_set->size!=0) {
+ if (sr_set->size!=1) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Storage Pool Name is not unique");
+ xen_sr_set_free(sr_set);
+ return -1;
+ }
+ sr = sr_set->contents[0];
+ if (xen_sr_get_vdis(session, &vdi_set, sr) && vdi_set->size!=0) {
+ count = vdi_set->size;
+ xen_sr_set_free(sr_set);
+ xen_vdi_set_free(vdi_set);
+ return count;
+ } else {
+ if (vdi_set) {
+ xen_vdi_set_free(vdi_set);
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Volume not found");
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ return -1;
+ }
+ } else {
+ if (sr_set) {
+ xen_sr_set_free(sr_set);
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Storage Pool not found");
+ return -1;
+ }
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ return -1;
+ }
+}
+
+
+/*
+*XenapiStoragePoolListVolumes
+*
+*Fetch list of storage volume names, limiting to at most maxnames.
+*
+*/
+static int
+xenapiStoragePoolListVolumes (virStoragePoolPtr pool, char ** const names,
+ int maxnames)
+{
+ xen_sr_set *sr_set=NULL;
+ xen_sr sr=NULL;
+ xen_vdi_set *vdi_set=NULL;
+ xen_vdi vdi=NULL;
+ int count,i;
+ char *usenames = NULL;
+ virConnectPtr conn=pool->conn;
+ xen_session *session = ((struct _xenapiStoragePrivate *)(conn->storagePrivateData))->session;
+ if (xen_sr_get_by_name_label(session, &sr_set, pool->name) && sr_set->size>0) {
+ if (sr_set->size!=1) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Storage Pool name is not unique");
+ xen_sr_set_free(sr_set);
+ return -1;
+ }
+ sr = sr_set->contents[0];
+ if (xen_sr_get_vdis(session, &vdi_set, sr) && vdi_set->size>0) {
+ for (i=0,count=0; (i<vdi_set->size) && (count<maxnames); i++) {
+ vdi = vdi_set->contents[i];
+ if (xen_vdi_get_name_label(session, &usenames, vdi)) {
+ names[count++] = usenames;
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ xen_vdi_set_free(vdi_set);
+ xen_sr_set_free(sr_set);
+ while(--count) VIR_FREE(names[count]);
+ return -1;
+ }
+ }
+ xen_vdi_set_free(vdi_set);
+ } else {
+ if (vdi_set) {
+ xen_vdi_set_free(vdi_set);
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Volume not found");
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ return -1;
+ }
+ xen_sr_set_free(sr_set);
+ return count;
+ } else {
+ if (sr_set) {
+ xen_sr_set_free(sr_set);
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Storage Pool not found");
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ }
+ return -1;
+}
+
+/*
+*XenapiStoragePoolIsActive
+*
+*Determine if the storage pool is currently running
+*
+*/
+static int
+xenapiStoragePoolIsActive(virStoragePoolPtr pool)
+{
+ xen_sr sr=NULL;
+ xen_pbd_set *pbd_set=NULL;
+ virConnectPtr conn=pool->conn;
+ char uuid[VIR_UUID_STRING_BUFLEN];
+ xen_session *session = ((struct _xenapiStoragePrivate *)(conn->storagePrivateData))->session;
+ virUUIDFormat(pool->uuid,uuid);
+
+ if (xen_sr_get_by_uuid(session, &sr, uuid)) {
+ if (xen_sr_get_pbds(session, &pbd_set, sr) && pbd_set->size>0) {
+ bool currently_attached;
+ xen_pbd_get_currently_attached(session, ¤tly_attached, pbd_set->contents[0]);
+ xen_pbd_set_free(pbd_set);
+ xen_sr_free(sr);
+ if (currently_attached == 1)
+ return 1; /* running */
+ else
+ return 0; /* not running */
+ } else {
+ if (pbd_set) {
+ xen_pbd_set_free(pbd_set);
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Physical Block Device not found");
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ xen_sr_free(sr);
+ return -1;
+ }
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ return -1;
+}
+
+/*
+*XenapiStoragePoolLookupByUUID
+*
+*Lookup the storage pool by UUID
+*
+*/
+static virStoragePoolPtr
+xenapiStoragePoolLookupByUUID (virConnectPtr conn,
+ const unsigned char * uuid)
+{
+ xen_sr sr = NULL;
+ xen_sr_record *record = NULL;
+ char uuidStr[VIR_UUID_STRING_BUFLEN];
+ virStoragePoolPtr pool = NULL;
+ xen_session *session = ((struct _xenapiStoragePrivate *)(conn->storagePrivateData))->session;
+ virUUIDFormat(uuid,uuidStr);
+ if (xen_sr_get_by_uuid(session, &sr, uuidStr) && sr) {
+ if (xen_sr_get_record(session, &record, sr)) {
+ pool = virGetStoragePool(conn, record->name_label, uuid);
+ if (!pool) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Couldn't get storage pool pointer");
+ xen_sr_record_free(record);
+ return pool;
+ }
+ xen_sr_record_free(record);
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ xen_sr_free(sr);
+ }
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_NO_STORAGE_POOL, NULL);
+ }
+ return pool;
+}
+
+
+/*
+*XenapiStoragePoolGetInfo
+*
+*Get information regarding the given storage pool
+*
+*/
+static int
+xenapiStoragePoolGetInfo (virStoragePoolPtr pool,
+ virStoragePoolInfoPtr info)
+{
+ xen_sr_record *record=NULL;
+ xen_sr sr=NULL;
+ virConnectPtr conn = pool->conn;
+ int state = -1;
+ char uuid[VIR_UUID_STRING_BUFLEN];
+ xen_session *session = ((struct _xenapiStoragePrivate *)(conn->storagePrivateData))->session;
+ virUUIDFormat(pool->uuid,uuid);
+ if (xen_sr_get_by_uuid(session, &sr, uuid) && sr) {
+ if (xen_sr_get_record(session, &record, sr)) {
+ info->capacity = record->physical_size;
+ info->allocation = record->virtual_allocation;
+ info->available = record->physical_size - record->physical_utilisation;
+ state = xenapiStoragePoolIsActive(pool);
+ if(state == 1) info->state = VIR_STORAGE_POOL_RUNNING;
+ else if(state == 0) info->state = VIR_STORAGE_POOL_INACTIVE;
+ xen_sr_record_free(record);
+ return 0;
+ } else {
+ xen_sr_free(sr);
+ xenapiSessionErrorHandler(conn, VIR_ERR_NO_STORAGE_POOL, NULL);
+ return -1;
+ }
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ return -1;
+ }
+}
+
+/*
+*XenapiStoragePoolLookupByVolume
+*
+*Lookup storage pool from the volume given
+*
+*/
+static virStoragePoolPtr
+xenapiStoragePoolLookupByVolume (virStorageVolPtr vol)
+{
+ xen_sr_record *record=NULL;
+ xen_sr_set *sr_set=NULL;
+ xen_sr sr=NULL;
+ virStoragePoolPtr poolPtr=NULL;
+ virConnectPtr conn = vol->conn;
+ unsigned char raw_uuid[VIR_UUID_BUFLEN];
+ xen_session *session = ((struct _xenapiStoragePrivate *)(conn->storagePrivateData))->session;
+
+ if (xen_sr_get_by_name_label(session, &sr_set, vol->pool) && sr_set->size>0) {
+ if (sr_set->size!=1) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Storage Pool name is not unique");
+ xen_sr_set_free(sr_set);
+ return NULL;
+ }
+ sr = sr_set->contents[0];
+ xen_sr_get_record(session, &record, sr);
+ if (record!=NULL) {
+ virUUIDParse(record->uuid,raw_uuid);
+ poolPtr = virGetStoragePool(conn,(const char *)record->name_label, raw_uuid);
+ if (poolPtr != NULL) {
+ xen_sr_record_free(record);
+ xen_sr_set_free(sr_set);
+ return poolPtr;
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Storage Pool pointer unavailable");
+ }
+ xen_sr_record_free(record);
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ xen_sr_set_free(sr_set);
+ } else {
+ if (sr_set) {
+ xen_sr_set_free(sr_set);
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Storage Pool not found");
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ }
+ return NULL;
+}
+
+/*
+*XenapiStorageVolLookupByName
+*
+*Lookup Storage volume by unique name
+*
+*/
+static virStorageVolPtr
+xenapiStorageVolLookupByName (virStoragePoolPtr pool,
+ const char *name)
+{
+ xen_vdi_set *vdi_set=NULL;
+ xen_vdi vdi=NULL;
+ virStorageVolPtr volPtr=NULL;
+ virConnectPtr conn = pool->conn;
+ char *uuid=NULL;
+ xen_session *session = ((struct _xenapiStoragePrivate *)(conn->storagePrivateData))->session;
+
+ if (xen_vdi_get_by_name_label(session, &vdi_set, (char *)name) && vdi_set->size>0) {
+ if (vdi_set->size!=1) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Storage Volume name is not unique");
+ xen_vdi_set_free(vdi_set);
+ return NULL;
+ }
+ vdi = vdi_set->contents[0];
+ if (xen_vdi_get_uuid(session, &uuid, vdi)) {
+ volPtr = virGetStorageVol(conn, pool->name, name, uuid);
+ if (!volPtr) xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Storage Volume pointer not available");
+ VIR_FREE(uuid);
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Couldn't find the Unique key of the Storage Volume specified");
+ }
+ xen_vdi_set_free(vdi_set);
+ } else {
+ if (vdi_set) {
+ xen_vdi_set_free(vdi_set);
+ xenapiSessionErrorHandler(conn, VIR_ERR_NO_STORAGE_VOL, "Storage Volume not found");
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ }
+ return volPtr;
+}
+
+/*
+*XenapiStorageVolGetInfo
+*
+*Get information about the given storage volume
+*
+*/
+static int
+xenapiStorageVolGetInfo (virStorageVolPtr vol,
+ virStorageVolInfoPtr info)
+{
+ virConnectPtr conn = vol->conn;
+ xen_vdi vdi=NULL;
+ xen_vdi_record *record=NULL;
+ xen_sr sr=NULL;
+ xen_sr_record *sr_record=NULL;
+ xen_session *session = ((struct _xenapiStoragePrivate *)(conn->storagePrivateData))->session;
+ int ret=-1;
+ //char uuid[VIR_UUID_STRING_BUFLEN];
+ //virUUIDFormat((unsigned char *)vol->key,uuid);
+
+ if (xen_vdi_get_by_uuid(session, &vdi, vol->key)) {
+ if (xen_vdi_get_record(session, &record, vdi)) {
+ info->capacity = record->virtual_size;
+ info->allocation = record->physical_utilisation;
+ if (xen_vdi_get_sr(session, &sr, vdi)) {
+ if (xen_sr_get_record(session, &sr_record, sr)) {
+ info->type = getStorageVolumeType(sr_record->type);
+ xen_sr_record_free(sr_record);
+ ret=0;
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ xen_vdi_record_free(record);
+ } else {
+ xen_vdi_free(vdi);
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ return ret;
+}
+
+static int
+xenapiStoragePoolIsPersistent (virStoragePoolPtr pool ATTRIBUTE_UNUSED)
+{
+ return 1; /* Storage Pool is always persistent */
+}
+
+
+/*
+*XenapiStorageVolGetXMLDesc
+*
+*Get Storage Volume configuration as XML
+*
+*/
+static char *
+xenapiStorageVolGetXMLDesc (virStorageVolPtr vol, unsigned int flags ATTRIBUTE_UNUSED)
+{
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+ virConnectPtr conn = vol->conn;
+ xen_vdi vdi=NULL;
+ xen_sr sr=NULL;
+ xen_vdi_record *record=NULL;
+ char *sr_uuid =NULL, *srname=NULL, *xml=NULL, *poolXml=NULL;
+ unsigned char raw_uuid[VIR_UUID_BUFLEN];
+ virStorageVolDefPtr vdef=NULL;
+ virStoragePoolDefPtr pdef=NULL;
+ virStoragePoolPtr pool=NULL;
+
+ xen_session *session = ((struct _xenapiStoragePrivate *)(conn->storagePrivateData))->session;
+ if (xen_vdi_get_by_uuid(session, &vdi, vol->key)) {
+ if (!xen_vdi_get_record(session, &record, vdi)) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Couldn't get Volume information");
+ xen_vdi_free(vdi);
+ virBufferFreeAndReset(&buf);
+ return NULL;
+ }
+ if (VIR_ALLOC(vdef)<0) {
+ virReportOOMError();
+ virBufferFreeAndReset(&buf);
+ xen_vdi_record_free(record);
+ return NULL;
+ }
+ if (!(vdef->name = strdup(record->name_label))) {
+ virReportOOMError();
+ virBufferFreeAndReset(&buf);
+ xen_vdi_record_free(record);
+ virStorageVolDefFree(vdef);
+ return NULL;
+ }
+ if (!(vdef->key = strdup(record->uuid))) {
+ virReportOOMError();
+ virBufferFreeAndReset(&buf);
+ xen_vdi_record_free(record);
+ virStorageVolDefFree(vdef);
+ return NULL;
+ }
+ vdef->allocation = record->virtual_size;
+ vdef->capacity = record->physical_utilisation;
+
+ if (xen_vdi_get_sr(session, &sr, vdi) && xen_sr_get_uuid(session, &sr_uuid, sr)) {
+ virBufferVSprintf(&buf, "/%s/%s", sr_uuid, record->uuid);
+ vdef->target.path = virBufferContentAndReset(&buf);
+ }
+ xen_sr_get_name_label(session, &srname, sr);
+ if (sr) xen_sr_free(sr);
+ xen_vdi_record_free(record);
+
+ virUUIDParse(sr_uuid, raw_uuid);
+ if(!(pool = virGetStoragePool(conn, srname, raw_uuid))) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Could get storage pool pointer");
+ VIR_FREE(srname);
+ VIR_FREE(sr_uuid);
+ virStorageVolDefFree(vdef);
+ return NULL;
+ }
+ VIR_FREE(srname);
+ VIR_FREE(sr_uuid);
+ if (!(poolXml = xenapiStoragePoolGetXMLDesc(pool, 0))) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Couldn't get Storage Pool XML");
+ virStorageVolDefFree(vdef);
+ return NULL;
+ }
+ if(!(pdef = virStoragePoolDefParseString(poolXml))) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Couldn't parse Storage Pool XML");
+ VIR_FREE(poolXml);
+ virStorageVolDefFree(vdef);
+ return NULL;
+ }
+ VIR_FREE(poolXml);
+ if(!(xml = virStorageVolDefFormat(pdef, vdef))) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Couldn't convert Storage Volume info to XML");
+ virStorageVolDefFree(vdef);
+ virStoragePoolDefFree(pdef);
+ return NULL;
+ }
+ virStorageVolDefFree(vdef);
+ virStoragePoolDefFree(pdef);
+ return xml;
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ return NULL;
+ }
+}
+
+/*
+*XenapiStorageVolLookupByPath
+*
+*Lookup Storage Volume for the given path
+*
+*/
+static virStorageVolPtr
+xenapiStorageVolLookupByPath (virConnectPtr conn,
+ ATTRIBUTE_UNUSED const char * path)
+{
+ xen_sr sr=NULL;
+ xen_vdi vdi=NULL;
+ virStorageVolPtr volPtr=NULL;
+ char *srname=NULL,*vname=NULL;
+ char sruuid[VIR_UUID_STRING_BUFLEN]="\0", vuuid[VIR_UUID_STRING_BUFLEN]="\0";
+ xen_session *session = ((struct _xenapiStoragePrivate *)(conn->storagePrivateData))->session;
+
+ sscanf(path,"/%[^/]/%[^/]",sruuid,vuuid);
+ if (STREQ(sruuid,"\0") || STREQ(vuuid,"\0")) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Invalid path");
+ return NULL;
+ }
+ if (xen_sr_get_by_uuid(session, &sr, sruuid) && xen_sr_get_name_label(session, &srname, sr)) {
+ if (xen_vdi_get_by_uuid(session, &vdi, vuuid) && xen_vdi_get_name_label(session, &vname, vdi)) {
+ if (!(volPtr = virGetStorageVol(conn, srname, vname, vuuid)))
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Storage Volume pointer not available");
+ VIR_FREE(vname);
+ xen_vdi_free(vdi);
+ } else {
+ if (vdi) xen_vdi_free(vdi);
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ VIR_FREE(srname);
+ xen_sr_free(sr);
+ } else {
+ if (sr) xen_sr_free(sr);
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ return volPtr;
+}
+
+/*
+*XenapiStorageVolGetPath
+*
+*Get path for the specified storage volume
+*
+*/
+static char *
+xenapiStorageVolGetPath (virStorageVolPtr vol)
+{
+ xen_vdi vdi=NULL;
+ virConnectPtr conn = vol->conn;
+ virBuffer path = VIR_BUFFER_INITIALIZER;
+ xen_sr sr=NULL;
+ char *sruuid=NULL;
+ xen_session *session = ((struct _xenapiStoragePrivate *)(conn->storagePrivateData))->session;
+
+ if (xen_vdi_get_by_uuid(session, &vdi, vol->key)) {
+ if (xen_vdi_get_sr(session, &sr, vdi) && xen_sr_get_uuid(session, &sruuid, sr)) {
+ virBufferVSprintf(&path,"/%s/%s",sruuid,vol->key);
+ VIR_FREE(sruuid);
+ xen_sr_free(sr);
+ } else {
+ if (sr) xen_sr_free(sr);
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ xen_vdi_free(vdi);
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ return virBufferContentAndReset(&path);
+}
+
+static int
+xenapiStoragePoolRefresh ( ATTRIBUTE_UNUSED virStoragePoolPtr pool,
+ ATTRIBUTE_UNUSED unsigned int flags)
+{
+ return 0;
+}
+
+/*
+*XenapiStorageVolLookupByKey
+*
+*Lookup storage volume for the given key
+*
+*/
+static virStorageVolPtr
+xenapiStorageVolLookupByKey (virConnectPtr conn, const char * key)
+{
+ xen_vdi vdi=NULL;
+ xen_sr sr=NULL;
+ xen_vdi_record *vrecord=NULL;
+ xen_sr_record *srecord=NULL;
+ virStorageVolPtr volPtr=NULL;
+ xen_session *session = ((struct _xenapiStoragePrivate *)(conn->storagePrivateData))->session;
+ if (xen_vdi_get_by_uuid(session, &vdi, (char *)key) && xen_vdi_get_record(session, &vrecord, vdi)) {
+ if (xen_vdi_get_sr(session, &sr, vdi) && xen_sr_get_record(session, &srecord, sr)) {
+ volPtr = virGetStorageVol(conn, srecord->name_label, vrecord->name_label, key);
+ if (!volPtr)
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Storage Volume Pointer not available");
+ xen_sr_record_free(srecord);
+ } else {
+ if (sr) xen_sr_free(sr);
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ xen_vdi_record_free(vrecord);
+ } else {
+ if (vdi) xen_vdi_free(vdi);
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ return volPtr;
+}
+
+
+/*
+*XenapiStoragePoolDestroy
+*
+*unplug PBDs connected to the specified storage pool
+*
+*/
+static int
+xenapiStoragePoolDestroy (virStoragePoolPtr pool)
+{
+ xen_sr sr=NULL;
+ xen_pbd pbd=NULL;
+ char uuidStr[VIR_UUID_STRING_BUFLEN];
+ struct xen_pbd_set *pbd_set=NULL;
+ int i,ret=-1;
+ virConnectPtr conn = pool->conn;
+ xen_session *session = ((struct _xenapiStoragePrivate *)(conn->storagePrivateData))->session;
+ virUUIDFormat(pool->uuid,uuidStr);
+ if (xen_sr_get_by_uuid(session, &sr, uuidStr)) {
+ if (xen_sr_get_pbds(session, &pbd_set, sr) && pbd_set->size>0) {
+ for (i=0;i<pbd_set->size;i++) {
+ pbd = pbd_set->contents[0];
+ if (xen_pbd_unplug(session, pbd))
+ ret=0;
+ else
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ xen_pbd_set_free(pbd_set);
+ } else {
+ if (pbd_set) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "There are no PBDs in the specified pool to unplug");
+ xen_pbd_set_free(pbd_set);
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ }
+ xen_sr_free(sr);
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ return ret;
+}
+
+static virStorageDriver xenapiStorageDriver = {
+ "XenAPI Storage",
+ xenapiStorageOpen,
+ xenapiStorageClose,
+ xenapiNumOfStoragePools,
+ xenapiListStoragePools,
+ xenapiNumOfDefinedStoragePools,
+ xenapiListDefinedStoragePools,
+ NULL,
+ xenapiStoragePoolLookupByName,
+ xenapiStoragePoolLookupByUUID,
+ xenapiStoragePoolLookupByVolume,
+ xenapiStoragePoolCreateXML,
+ NULL,
+ xenapiStoragePoolBuild,
+ NULL,
+ xenapiStoragePoolCreate,
+ xenapiStoragePoolDestroy,
+ NULL,
+ xenapiStoragePoolRefresh,
+ xenapiStoragePoolGetInfo,
+ xenapiStoragePoolGetXMLDesc,
+ xenapiStoragePoolGetAutostart,
+ xenapiStoragePoolSetAutostart,
+ xenapiStoragePoolNumOfVolumes,
+ xenapiStoragePoolListVolumes,
+ xenapiStorageVolLookupByName,
+ xenapiStorageVolLookupByKey,
+ xenapiStorageVolLookupByPath,
+ NULL,
+ NULL,
+ NULL,
+ xenapiStorageVolGetInfo,
+ xenapiStorageVolGetXMLDesc,
+ xenapiStorageVolGetPath,
+ xenapiStoragePoolIsActive,
+ xenapiStoragePoolIsPersistent
+};
+
+
+/*
+*XenapiStorageRegister
+*
+*Register the storage driver APIs
+*
+*/
+int
+xenapiStorageRegister (void)
+{
+ return virRegisterStorageDriver(&xenapiStorageDriver);
+}
+
+
+
+
--- ./libvirt_org/src/xenapi/xenapi_storage_driver.h 1970-01-01 01:00:00.000000000 +0100
+++ ./libvirt/src/xenapi/xenapi_storage_driver.h 2010-03-11 12:46:00.000000000 +0000
@@ -0,0 +1,42 @@
+/*
+ * xenapi_storage_driver.h: Xen API Storage Driver header file
+ * Copyright (C) 2009, 2010 Citrix Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Sharadha Prabhakar <sharadha.prabhakar(a)citrix.com>
+ */
+
+
+#ifndef __VIR_XENAPI_STORAGE_H__
+#define __VIR_XENAPI_STORAGE_H__
+
+#include <xen/api/xen_common.h>
+#include <libxml/tree.h>
+
+
+
+/* XenAPI storage driver's private data structure */
+struct _xenapiStoragePrivate {
+ xen_session *session;
+ char *url;
+ int noVerify;
+ virCapsPtr caps;
+};
+
+
+
+
+#endif /* __VIR_XENAPI_STORAGE_H__ */
--- ./src/xenapi/xenapi_utils.h_orig 2010-03-24 15:38:59.000000000 +0000
+++ ./src/xenapi/xenapi_utils.h 2010-03-23 10:44:38.000000000 +0000
@@ -56,8 +56,12 @@
#include "buf.h"
#define NETWORK_DEVID_SIZE (12)
+#define STORAGE_DEVID_SIZE (12)
typedef uint64_t cpumap_t;
+//newly added
+int
+createVbdStorage (virConnectPtr conn, xen_vm vm, int device, char *path, int devtype);
void
xenSessionFree(xen_session *session);
--- ./src/xenapi/xenapi_utils.c_orig 2010-03-24 15:32:28.000000000 +0000
+++ ./src/xenapi/xenapi_utils.c 2010-03-24 15:09:41.000000000 +0000
@@ -53,6 +53,7 @@
#include "xenapi_utils.h"
#include "util/logging.h"
#include "qparams.h"
+#include "xenapi_storage_driver.h"
void
xenSessionFree(xen_session *session)
@@ -390,17 +391,96 @@
const char *buf, const char *filename, const char *func, size_t lineno)
{
struct _xenapiPrivate *priv = conn->privateData;
-
- if (buf == NULL && priv != NULL && priv->session != NULL) {
- char *ret = returnErrorFromSession(priv->session);
- virReportErrorHelper(conn, VIR_FROM_XENAPI, errNum, filename, func, lineno, _("%s"), ret);
- xen_session_clear_error(priv->session);
- VIR_FREE(ret);
+ struct _xenapiStoragePrivate *privS = conn->storagePrivateData;
+ char *ret = NULL;
+ if (buf == NULL) {
+ if (priv != NULL && priv->session != NULL) {
+ if (!priv->session->ok) {
+ ret = returnErrorFromSession(priv->session);
+ virReportErrorHelper(conn, VIR_FROM_XENAPI, errNum, filename, func, lineno, _("%s"), ret);
+ xen_session_clear_error(priv->session);
+ VIR_FREE(ret);
+ }
+ }
+ if (privS != NULL && privS->session !=NULL) {
+ if (!privS->session->ok) {
+ ret = returnErrorFromSession(privS->session);
+ virReportErrorHelper(conn, VIR_FROM_XENAPI, errNum, filename, func, lineno, _("%s"), ret);
+ xen_session_clear_error(privS->session);
+ VIR_FREE(ret);
+ }
+ }
} else {
virReportErrorHelper(conn, VIR_FROM_XENAPI, errNum, filename, func, lineno, _("%s"), buf);
}
}
+/* create VBDs for VM */
+int
+createVbdStorage (virConnectPtr conn, xen_vm vm, int device, char *path, int devtype)
+{
+ xen_vm xvm=NULL;
+ xen_vdi vdi=NULL;
+ xen_vbd vbd=NULL;
+ char *vmuuid=NULL;
+ char userdevice[STORAGE_DEVID_SIZE]="\0";
+ xen_vbd_record *record=NULL;
+ xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
+ char sruuid[VIR_UUID_STRING_BUFLEN]="\0", voluuid[VIR_UUID_STRING_BUFLEN]="\0";
+ if (sscanf(path,"/%[^/]/%[^/]",sruuid,voluuid)!=2)
+ return -1;
+ fprintf(stderr,"\nsruuid: %s\nvoluuid: %s",sruuid,voluuid);
+ if (!xen_vm_get_uuid(session, &vmuuid, vm))
+ return -1;
+ if (!xen_vm_get_by_uuid(session, &xvm, vmuuid)){
+ VIR_FREE(vmuuid);
+ return -1;
+ }
+ VIR_FREE(vmuuid);
+ if (!xen_vdi_get_by_uuid(session, &vdi, voluuid)) {
+ xen_vm_free(xvm);
+ return -1;
+ }
+ sprintf(userdevice,"%d",device);
+ xen_vm_record_opt *vm_opt = xen_vm_record_opt_alloc();
+ vm_opt->is_record = 0;
+ vm_opt->u.handle = xvm;
+
+ xen_vdi_record_opt *vdi_opt = xen_vdi_record_opt_alloc();
+ vdi_opt->is_record = 0;
+ vdi_opt->u.handle = vdi;
+
+ record = xen_vbd_record_alloc();
+ record->vm = vm_opt;
+ record->vdi = vdi_opt;
+ if (!(record->userdevice = strdup(userdevice))) {
+ xen_vbd_record_free(record);
+ return -1;
+ }
+ record->other_config = xen_string_string_map_alloc(0);
+ record->runtime_properties = xen_string_string_map_alloc(0);
+ record->qos_algorithm_params = xen_string_string_map_alloc(0);
+ if (devtype == VIR_DOMAIN_DISK_DEVICE_DISK)
+ record->type = XEN_VBD_TYPE_DISK;
+ else if (devtype == VIR_DOMAIN_DISK_DEVICE_CDROM)
+ record->type = XEN_VBD_TYPE_CD;
+ else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Only CDROM and HardDisk supported");
+ xen_vbd_record_free(record);
+ return -1;
+ }
+ if (!xen_vbd_create(session, &vbd, record)){
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ xen_vbd_record_free(record);
+ return -1;
+ }
+ xen_vbd_record_free(record);
+
+ return 0;
+}
+
+
+
/* creates network intereface for VM */
int
createVifNetwork (virConnectPtr conn, xen_vm vm, char *device,
@@ -557,6 +637,7 @@
int device_number=0;
char *bridge=NULL,*mac=NULL;
int i;
+ //support for network interfaces
for (i=0;i<def->nnets;i++) {
if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
if (def->nets[i]->data.bridge.brname)
@@ -580,6 +661,13 @@
if (bridge) VIR_FREE(bridge);
}
}
+ //support for disks here
+ for (i=0;i<def->ndisks;i++) {
+ if (createVbdStorage(conn, *vm, i, def->disks[i]->src, def->disks[i]->device)!= 0) {
+ xen_vm_record_free(*record);
+ return -1;
+ }
+ }
return 0;
error_cleanup:
--- ../libvirt_org/src/conf/storage_conf.c 2010-02-17 17:38:05.000000000 +0000
+++ ./src/conf/storage_conf.c 2010-03-22 15:08:36.000000000 +0000
@@ -61,7 +61,7 @@
VIR_ENUM_IMPL(virStoragePoolFormatFileSystemNet,
VIR_STORAGE_POOL_NETFS_LAST,
- "auto", "nfs", "glusterfs")
+ "auto", "nfs", "nfs-iso", "cifs-iso", "glusterfs")
VIR_ENUM_IMPL(virStoragePoolFormatDisk,
VIR_STORAGE_POOL_DISK_LAST,
--- ../libvirt_org/src/conf/storage_conf.h 2010-02-17 17:38:06.000000000 +0000
+++ ./src/conf/storage_conf.h 2010-03-22 14:01:02.000000000 +0000
@@ -404,6 +404,8 @@
enum virStoragePoolFormatFileSystemNet {
VIR_STORAGE_POOL_NETFS_AUTO = 0,
VIR_STORAGE_POOL_NETFS_NFS,
+ VIR_STORAGE_POOL_NETFS_NFS_ISO,
+ VIR_STORAGE_POOL_NETFS_CIFS_ISO,
VIR_STORAGE_POOL_NETFS_GLUSTERFS,
VIR_STORAGE_POOL_NETFS_LAST,
};
--- ./src/Makefile.am_04mar 2010-03-05 10:55:04.000000000 +0000
+++ ./src/Makefile.am 2010-03-23 18:11:50.000000000 +0000
@@ -210,7 +211,9 @@
XENAPI_DRIVER_SOURCES = \
xenapi/xenapi_driver.c xenapi/xenapi_driver.h \
xenapi_driver_private.h \
- xenapi/xenapi_utils.c xenapi/xenapi_utils.h
+ xenapi/xenapi_utils.c xenapi/xenapi_utils.h \
+ xenapi/xenapi_storage_driver.c \
+ xenapi/xenapi_storage_driver.h
UML_DRIVER_SOURCES = \
uml/uml_conf.c uml/uml_conf.h \
--- ../libvirt_org/src/libvirt.c 2010-02-17 17:38:08.000000000 +0000
+++ ./src/libvirt.c 2010-03-11 12:14:33.000000000 +0000
@@ -377,6 +381,10 @@
#ifdef WITH_ESX
if (esxRegister() == -1) return -1;
#endif
#ifdef WITH_XENAPI
if (xenapiRegister () == -1) return -1;
+ if (xenapiStorageRegister () == -1) return -1;
#endif
#ifdef WITH_REMOTE
if (remoteRegister () == -1) return -1;
#endif
--- ./src/xenapi/xenapi_driver.h_orig 2010-03-23 19:00:14.000000000 +0000
+++ ./src/xenapi/xenapi_driver.h 2010-03-11 11:11:01.000000000 +0000
@@ -25,5 +25,6 @@
extern int xenapiRegister (void);
+extern int xenapiStorageRegister (void);
#endif /* __VIR_XENAPI_PRIV_H__ */
1
1
26 Mar '10
Hello,
While using multiple disk devices with different bus types (ide and virtio)
I noticed that the order of disks is handled in a special way.
The disk device which was defined as the first item will not be the first
entry in the system xml file.
e.g. if I define a virtio device (which is supposed to be the boot device)
this would be added after all the ide devices.
So it's not possible to boot from a virtio device even if I have defined
other ide devices since qemu flags the first device as boot device.
Is there a special reason why the disks are sorted by type (first all ide
and then virtio) because that's prevents from booting virtio devices.
Thanks.
Mit freundlichen Grüßen / Kind regards
Ingo Tuchscherer
1
0
No big deal, but I saw recent additions of "test ... -a ..."
(not portable) so fixed the rest, too.
Now, searching for violations shows none:
git grep '\<test .* -a '
Whether it's possible to rely on test -a in test scripts is debatable:
perhaps you've ensured that the SHELL you use when running tests is
POSIX compliant or better (I do that in coreutils), but at least in
configure.ac, we should toe the line wrt portability (because *it*
has less choice), so those are in a separate commit.
Since this is a global change, it deserves a syntax-check rule.
That's the 3/3 patch, below.
1/3 fixes test-lib.sh
2/3 fixes configure.ac
>From ca7db6cb8000cc283fcee7899140d2fc892b0296 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 24 Mar 2010 09:05:27 +0100
Subject: [PATCH 1/3] tests: shell script portability and clean-up
* tests/test-lib.sh: "echo -n" is not portable. Use printf instead.
Remove unnecessary uses of "eval-in-subshell" (subshell is sufficient).
Remove uses of tests' -a operator; it is not portable.
Instead, use "test cond && test cond2".
* tests/schematestutils.sh: Replace use of test's -a.
---
tests/schematestutils.sh | 2 +-
tests/test-lib.sh | 20 ++++++++++----------
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/tests/schematestutils.sh b/tests/schematestutils.sh
index 301b9eb..f172857 100644
--- a/tests/schematestutils.sh
+++ b/tests/schematestutils.sh
@@ -21,7 +21,7 @@ do
ret=$?
test_result $n $(basename $(dirname $xml))"/"$(basename $xml) $ret
- if test "$verbose" = "1" -a $ret != 0 ; then
+ if test "$verbose" = "1" && test $ret != 0 ; then
echo -e "$cmd\n$result"
fi
if test "$ret" != 0 ; then
diff --git a/tests/test-lib.sh b/tests/test-lib.sh
index 57fd438..28b830e 100644
--- a/tests/test-lib.sh
+++ b/tests/test-lib.sh
@@ -19,7 +19,7 @@ test_intro()
name=$1
if test "$verbose" = "0" ; then
echo "TEST: $name"
- echo -n " "
+ printf " "
fi
}
@@ -29,15 +29,15 @@ test_result()
name=$2
status=$3
if test "$verbose" = "0" ; then
- mod=`eval "expr \( $counter - 1 \) % 40"`
- if test "$counter" != 1 -a "$mod" = 0 ; then
- printf " %-3d\n" `eval "expr $counter - 1"`
- echo -n " "
+ mod=`expr \( $counter + 40 - 1 \) % 40`
+ if test "$counter" != 1 && test "$mod" = 0 ; then
+ printf " %-3d\n" `expr $counter - 1`
+ printf " "
fi
if test "$status" = "0" ; then
- echo -n "."
+ printf "."
else
- echo -n "!"
+ printf "!"
fi
else
if test "$status" = "0" ; then
@@ -54,11 +54,11 @@ test_final()
status=$2
if test "$verbose" = "0" ; then
- mod=`eval "expr \( $counter + 1 \) % 40"`
- if test "$mod" != "0" -a "$mod" != "1" ; then
+ mod=`expr \( $counter + 1 \) % 40`
+ if test "$mod" != "0" && test "$mod" != "1" ; then
for i in `seq $mod 40`
do
- echo -n " "
+ printf " "
done
fi
if test "$status" = "0" ; then
--
1.7.0.3.435.g097f4
>From 7998714d60b997357bfea15d6f2d0f729fc8fb29 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 24 Mar 2010 09:10:13 +0100
Subject: [PATCH 2/3] build: don't use "test cond1 -a cond2" in configure: it's not portable
* configure.ac: Use "test cond1 && test cond2" instead.
---
configure.ac | 26 +++++++++++++-------------
1 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/configure.ac b/configure.ac
index bcf1d5a..2e6d2e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -197,10 +197,10 @@ dnl if --prefix is /usr, don't use /usr/var for localstatedir
dnl or /usr/etc for sysconfdir
dnl as this makes a lot of things break in testing situations
-if test "$prefix" = "/usr" -a "$localstatedir" = '${prefix}/var' ; then
+if test "$prefix" = "/usr" && test "$localstatedir" = '${prefix}/var' ; then
localstatedir='/var'
fi
-if test "$prefix" = "/usr" -a "$sysconfdir" = '${prefix}/etc' ; then
+if test "$prefix" = "/usr" && test "$sysconfdir" = '${prefix}/etc' ; then
sysconfdir='/etc'
fi
@@ -240,7 +240,7 @@ AC_ARG_WITH([libvirtd],
dnl
dnl specific tests to setup DV devel environments with debug etc ...
dnl
-if [[ "${LOGNAME}" = "veillard" -a "`pwd`" = "/u/veillard/libvirt" ]] ; then
+if [[ "${LOGNAME}" = "veillard" && test "`pwd`" = "/u/veillard/libvirt" ]] ; then
STATIC_BINARIES="-static"
else
STATIC_BINARIES=
@@ -351,7 +351,7 @@ LIBXENSERVER_LIBS=""
LIBXENSERVER_CFLAGS=""
dnl search for the XenServer library
if test "$with_xenapi" != "no" ; then
- if test "$with_xenapi" != "yes" -a "$with_xenapi" != "check" ; then
+ if test "$with_xenapi" != "yes" && test "$with_xenapi" != "check" ; then
LIBXENSERVER_CFLAGS="-I$with_xenapi/include"
LIBXENSERVER_LIBS="-L$with_xenapi"
fi
@@ -390,7 +390,7 @@ XEN_LIBS=""
XEN_CFLAGS=""
dnl search for the Xen store library
if test "$with_xen" != "no" ; then
- if test "$with_xen" != "yes" -a "$with_xen" != "check" ; then
+ if test "$with_xen" != "yes" && test "$with_xen" != "check" ; then
XEN_CFLAGS="-I$with_xen/include"
XEN_LIBS="-L$with_xen/lib64 -L$with_xen/lib"
fi
@@ -571,7 +571,7 @@ AC_ARG_WITH([libxml], AC_HELP_STRING([--with-libxml=@<:@PFX@:>@], [libxml2 locat
if test "x$with_libxml" = "xno" ; then
AC_MSG_CHECKING(for libxml2 libraries >= $LIBXML_REQUIRED)
AC_MSG_ERROR([libxml2 >= $LIBXML_REQUIRED is required for libvirt])
-elif test "x$with_libxml" = "x" -a "x$PKG_CONFIG" != "x" ; then
+elif test "x$with_libxml" = "x" && test "x$PKG_CONFIG" != "x" ; then
PKG_CHECK_MODULES(LIBXML, libxml-2.0 >= $LIBXML_REQUIRED, [LIBXML_FOUND=yes], [LIBXML_FOUND=no])
fi
if test "$LIBXML_FOUND" = "no" ; then
@@ -661,7 +661,7 @@ AC_ARG_WITH([sasl],
SASL_CFLAGS=
SASL_LIBS=
if test "x$with_sasl" != "xno"; then
- if test "x$with_sasl" != "xyes" -a "x$with_sasl" != "xcheck"; then
+ if test "x$with_sasl" != "xyes" && test "x$with_sasl" != "xcheck"; then
SASL_CFLAGS="-I$with_sasl"
SASL_LIBS="-L$with_sasl"
fi
@@ -716,7 +716,7 @@ AC_ARG_WITH([yajl],
YAJL_CFLAGS=
YAJL_LIBS=
if test "x$with_yajl" != "xno"; then
- if test "x$with_yajl" != "xyes" -a "x$with_yajl" != "xcheck"; then
+ if test "x$with_yajl" != "xyes" && test "x$with_yajl" != "xcheck"; then
YAJL_CFLAGS="-I$with_yajl/include"
YAJL_LIBS="-L$with_yajl/lib"
fi
@@ -1004,7 +1004,7 @@ AC_ARG_WITH([numactl],
NUMACTL_CFLAGS=
NUMACTL_LIBS=
-if test "$with_qemu" = "yes" -a "$with_numactl" != "no"; then
+if test "$with_qemu" = "yes" && test "$with_numactl" != "no"; then
old_cflags="$CFLAGS"
old_libs="$LIBS"
if test "$with_numactl" = "check"; then
@@ -1062,7 +1062,7 @@ dnl
dnl libssh checks
dnl
-if test "$with_libssh2" != "yes" -a "$with_libssh2" != "no"; then
+if test "$with_libssh2" != "yes" && test "$with_libssh2" != "no"; then
libssh2_path="$with_libssh2"
elif test "$with_libssh2" = "yes"; then
libssh2_path="/usr/local/lib/"
@@ -1143,7 +1143,7 @@ dnl introduced in 0.4.0 release which need as minimum
dnl
CAPNG_CFLAGS=
CAPNG_LIBS=
-if test "$with_qemu" = "yes" -a "$with_capng" != "no"; then
+if test "$with_qemu" = "yes" && test "$with_capng" != "no"; then
old_cflags="$CFLAGS"
old_libs="$LIBS"
if test "$with_capng" = "check"; then
@@ -1453,7 +1453,7 @@ if test "$with_storage_disk" = "yes" -o "$with_storage_disk" = "check"; then
PARTED_FOUND=yes
fi
- if test "$with_storage_disk" != "no" -a "x$PKG_CONFIG" != "x" ; then
+ if test "$with_storage_disk" != "no" && test "x$PKG_CONFIG" != "x" ; then
PKG_CHECK_MODULES(LIBPARTED, libparted >= $PARTED_REQUIRED, [], [PARTED_FOUND=no])
fi
if test "$PARTED_FOUND" = "no"; then
@@ -1635,7 +1635,7 @@ else
fi
AC_MSG_RESULT($RUNNING_XEND)
-AM_CONDITIONAL([ENABLE_XEN_TESTS], [test "$RUNNING_XEN" != "no" -a "$RUNNING_XEND" != "no"])
+AM_CONDITIONAL([ENABLE_XEN_TESTS], [test "$RUNNING_XEN" != "no" && test "$RUNNING_XEND" != "no"])
AC_ARG_ENABLE([test-coverage],
AC_HELP_STRING([--enable-test-coverage], [turn on code coverage instrumentation @<:@default=no@:>@]),
--
1.7.0.3.435.g097f4
>From 95c8ddd2eca90e3024a6f74af84517c1e0115a60 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 24 Mar 2010 09:32:43 +0100
Subject: [PATCH 3/3] maint: add syntax-check rule to prohibit use of test's -a operator
* cfg.mk (sc_prohibit_test_minus_a): New rule.
---
cfg.mk | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 2d0d278..4302338 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -269,6 +269,12 @@ sc_preprocessor_indentation:
echo '$(ME): skipping test $@: cppi not installed' 1>&2; \
fi
+# Using test's -a operator is not portable.
+sc_prohibit_test_minus_a:
+ @re='\<test .+ -[a] ' \
+ msg='use "test C1 && test C2, not "test C1 -''a C2"' \
+ $(_prohibit_regexp)
+
sc_copyright_format:
@$(VC_LIST_EXCEPT) | xargs grep -ni 'copyright .*Red 'Hat \
| grep -v Inc \
--
1.7.0.3.435.g097f4
2
7