[libvirt] OSX 10.6 build failures
by Justin Clift
Hi us,
Going through the process of getting libvirt to compile on OSX, making
notes of the failures on the way through (from a clean system) to be fixed.
a) libtool -> glibtool
libtoolize -> glibtoolize
It turns out that autogen.sh is hard coded to use "libtool", and
wants the GNU version.
OSX supplies has it's own version, without a --version option, so
autogen.sh fails.
Installing GNU libtool through MacPorts, makes it available as
glibtool, with libtoolize being glibtoolize.
Adjusting autogen.sh to detect that, then set LIBTOOL and LIBTOOLIZE
appropriately was fairly trivial.
Will submit a patch to fix that in a bit.
b) pkg-config
The next thing to barf was autoconf, complaining about AC_MSG_ERROR
not being a defined macro.
Googling with some persistence showed this is caused by pkg-config
not being installed. Fixed that.
Will submit a patch for that too. Probably "pkg-config --version"
based, copying the approach used for the other autogen.sh checks.
c) This is a compilation failure, one I don't readily know how to fix:
...
Making all in src
make all-am
CC libvirt_util_la-network.lo
util/network.c: In function 'getIPv6Addr':
util/network.c:50: error: 'struct in6_addr' has no member named
's6_addr16'
util/network.c:50: error: 'struct in6_addr' has no member named
's6_addr16'
util/network.c:50: error: 'struct in6_addr' has no member named
's6_addr16'
util/network.c:50: error: 'struct in6_addr' has no member named
's6_addr16'
make[3]: *** [libvirt_util_la-network.lo] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
$
They're the only problems so far, though most things have been disabled
on the ./configure line so it's only the client libraries being built.
Anyone know how to address that third one?
Regards and best wishes,
Justin Clift
14 years, 2 months
Re: [libvirt] Here they
by Jaromír Červenka
Hi there,
Arnaud, where did you get latest source of my C# binding? Because my svn
server doesn't work a couple of months, so maybe you used old one. I
attached latest one in this mail.
I am so sorry that I discontinued work of my bindings for libivirt, but I
discovered Ruby language and I felt love in it and I ported my web interface
for libvirt - now is built on Chris's ruby-libvirt.
Arnaud I noticed that you didn't used my classes which "envelops" bare
libvirt functions, am I right? Good work anyway, I'm glad that part of my
job wont be lose :)
Regards,
Jaromír Červenka
Official openSUSE community member
Web: http://www.cervajz.com/
Jabber: cervajz(a)cervajz.com
MSN: jara.cervenka(a)seznam.cz
Tel.: +420 607 592 687
Alt. e-mails:
jaromir.cervenka(a)opensuse.org,
jaromir.cervenka(a)speel.cz
Dne 24. září 2010 17:47 <arnaud.champion(a)devatom.fr> napsal(a):
> I'm very away from a licence expert :) but I think that should be similar
> to libvirt, so LGPL 2 or later seems good for me.
>
> A lot of code comes from Jaromír, I have changed these things :
> - improve pinning and marshaling of struct, methods for using with C# and
> windows libvirt binaries
> - Add delegate to handle callbacks, this include pinnings and marshaling
> also (I have to work little on the pinning/marshaling of the delegate
> virConnectAuthCallback, because it seems that I have some trouble around
> packing structure virConnectCredential)
>
> I have also added some XML auto documentation descriptors.
>
>
>
> --------------------------------------------------
> From: "Daniel Veillard" <veillard(a)redhat.com>
> Sent: Friday, September 24, 2010 2:15 PM
> To: <arnaud.champion(a)devatom.fr>
> Cc: "Jaromír Červenka" <cervajz(a)cervajz.com>
> Subject: Re: Here they
>
>
> On Fri, Sep 24, 2010 at 11:29:51AM +0200, arnaud.champion(a)devatom.frwrote:
>>
>>> Hi,
>>>
>>
>> Bonjour,
>>
>> As I have said, here are the libvirt C# bindings that I have modified.
>>> For info, I use them in a project (DAVIM) and they work find, I will make a
>>> doc to explain what is covered and what is not...
>>>
>>> Let me know if you have any question.
>>>
>>
>> yes at least two:
>>
>> - what is the Licence for the code in that ZIP ? I would assume
>> LGPL version 2 or later, to be similar to libvirt itself
>> - how much of that code is coming from Jaromír ?
>>
>> thanks !
>>
>> PS : Sorry for my poor english. FYI, DAVIM, is a tool to create / manage
>>> Libvirt/KVM it is free to download at www.Devatom.fr the tol is in
>>> english or french but the website is in french only. Let me know if you want
>>> I send you the tool if you want to test it.
>>>
>>
>> Pas de probleme !
>> A priori je n'ai pas de C# ni de machine Windows donc pas tres utile
>> pour moi, mais merci ...
>>
>> 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/
>>
>>
>
14 years, 2 months
[libvirt] [PATCH] esx: Add support for virtual serial device network backing
by Matthias Bolte
Since version 4.1 ESX(i) can expose virtual serial devices over TCP.
Add support in the VMX handling code for this, add test cases to cover
it and add links to some documentation.
ESX supports two additional protocols: TELNETS and TLS. Add them to
the list of serial-over-TCP protocols.
---
docs/formatdomain.html.in | 4 +-
src/conf/domain_conf.c | 18 ++-
src/conf/domain_conf.h | 3 +
src/esx/README | 23 ++-
src/esx/esx_vmx.c | 163 ++++++++++++++++++--
.../vmx2xmldata/vmx2xml-serial-network-client.vmx | 6 +
.../vmx2xmldata/vmx2xml-serial-network-client.xml | 25 +++
.../vmx2xmldata/vmx2xml-serial-network-server.vmx | 6 +
.../vmx2xmldata/vmx2xml-serial-network-server.xml | 25 +++
tests/vmx2xmltest.c | 2 +
.../xml2vmxdata/xml2vmx-serial-network-client.vmx | 14 ++
.../xml2vmxdata/xml2vmx-serial-network-client.xml | 15 ++
.../xml2vmxdata/xml2vmx-serial-network-server.vmx | 14 ++
.../xml2vmxdata/xml2vmx-serial-network-server.xml | 15 ++
tests/xml2vmxtest.c | 2 +
15 files changed, 304 insertions(+), 31 deletions(-)
create mode 100644 tests/vmx2xmldata/vmx2xml-serial-network-client.vmx
create mode 100644 tests/vmx2xmldata/vmx2xml-serial-network-client.xml
create mode 100644 tests/vmx2xmldata/vmx2xml-serial-network-server.vmx
create mode 100644 tests/vmx2xmldata/vmx2xml-serial-network-server.xml
create mode 100644 tests/xml2vmxdata/xml2vmx-serial-network-client.vmx
create mode 100644 tests/xml2vmxdata/xml2vmx-serial-network-client.xml
create mode 100644 tests/xml2vmxdata/xml2vmx-serial-network-server.vmx
create mode 100644 tests/xml2vmxdata/xml2vmx-serial-network-server.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 5e56dae..2f64f8d 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1461,7 +1461,9 @@ qemu-kvm -net nic,model=? /dev/null
...</pre>
<p>
- Alternatively you can use telnet instead of raw TCP.
+ Alternatively you can use <code>telnet</code> instead of <code>raw</code> TCP.
+ <span class="since">Since 0.8.5</span> you can also use <code>telnets</code>
+ (secure telnet) and <code>tls</code>.
<p>
<pre>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e05d5d7..92aa3d1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -203,6 +203,12 @@ VIR_ENUM_IMPL(virDomainChr, VIR_DOMAIN_CHR_TYPE_LAST,
"tcp",
"unix")
+VIR_ENUM_IMPL(virDomainChrTcpProtocol, VIR_DOMAIN_CHR_TCP_PROTOCOL_LAST,
+ "raw",
+ "telnet",
+ "telnets",
+ "tls")
+
VIR_ENUM_IMPL(virDomainSoundModel, VIR_DOMAIN_SOUND_MODEL_LAST,
"sb16",
"es1370",
@@ -2748,12 +2754,10 @@ virDomainChrDefParseXML(virCapsPtr caps,
def->data.tcp.listen = 1;
}
- if (protocol == NULL ||
- STREQ(protocol, "raw"))
+ if (protocol == NULL)
def->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW;
- else if (STREQ(protocol, "telnet"))
- def->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET;
- else {
+ else if ((def->data.tcp.protocol =
+ virDomainChrTcpProtocolTypeFromString(protocol)) < 0) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown protocol '%s'"), protocol);
goto error;
@@ -5848,9 +5852,7 @@ virDomainChrDefFormat(virBufferPtr buf,
def->data.tcp.host,
def->data.tcp.service);
virBufferVSprintf(buf, " <protocol type='%s'/>\n",
- def->data.tcp.protocol ==
- VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET
- ? "telnet" : "raw");
+ virDomainChrTcpProtocolTypeToString(def->data.tcp.protocol));
break;
case VIR_DOMAIN_CHR_TYPE_UNIX:
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 7195c04..9bf13d8 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -357,6 +357,8 @@ enum virDomainChrType {
enum virDomainChrTcpProtocol {
VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW,
VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET,
+ VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNETS, /* secure telnet */
+ VIR_DOMAIN_CHR_TCP_PROTOCOL_TLS,
VIR_DOMAIN_CHR_TCP_PROTOCOL_LAST,
};
@@ -1172,6 +1174,7 @@ VIR_ENUM_DECL(virDomainChrDevice)
VIR_ENUM_DECL(virDomainChrChannelTarget)
VIR_ENUM_DECL(virDomainChrConsoleTarget)
VIR_ENUM_DECL(virDomainChr)
+VIR_ENUM_DECL(virDomainChrTcpProtocol)
VIR_ENUM_DECL(virDomainSoundModel)
VIR_ENUM_DECL(virDomainMemballoonModel)
VIR_ENUM_DECL(virDomainWatchdogModel)
diff --git a/src/esx/README b/src/esx/README
index 7254332..9ae93b1 100644
--- a/src/esx/README
+++ b/src/esx/README
@@ -3,13 +3,24 @@ Some links to relevant documentation
====================================
-VI/vSphere API: http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/
- http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/
-VMX config: http://www.sanbarrow.com/vmx.html
-CPUID: http://www.sandpile.org/ia32/cpuid.htm
-Memory model: http://www.vmware.com/pdf/esx3_memory.pdf
- http://www.vmware.com/pdf/usenix_resource_mgmt.pdf
+VI/vSphere API:
+ http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/
+ http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/
+ http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/
+VMX config:
+ http://www.sanbarrow.com/vmx.html
+
+CPUID:
+ http://www.sandpile.org/ia32/cpuid.htm
+
+Memory model:
+ http://www.vmware.com/pdf/esx3_memory.pdf
+ http://www.vmware.com/pdf/usenix_resource_mgmt.pdf
+
+Virtual serial port (network backed):
+ http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/v...
+ http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/vsp41_usingpro...
diff --git a/src/esx/esx_vmx.c b/src/esx/esx_vmx.c
index 59eb3b2..bfebc4a 100644
--- a/src/esx/esx_vmx.c
+++ b/src/esx/esx_vmx.c
@@ -379,6 +379,36 @@ def->serials[0]...
??? <=> serial0.yieldOnMsrRead = "true" # defaults to "false", FIXME: not representable
+## serials: network, server (since vSphere 4.1) ################################
+
+->type = _CHR_TYPE_TCP <=> serial0.fileType = "network"
+
+->data.tcp.host = <host> <=> serial0.fileName = "<protocol>://<host>:<service>"
+->data.tcp.service = <service> # e.g. "telnet://0.0.0.0:42001"
+->data.tcp.protocol = <protocol>
+
+->data.tcp.listen = 1 <=> serial0.network.endPoint = "server" # defaults to "server"
+
+??? <=> serial0.vspc = "foobar" # defaults to <not present>, FIXME: not representable
+??? <=> serial0.tryNoRxLoss = "false" # defaults to "false", FIXME: not representable
+??? <=> serial0.yieldOnMsrRead = "true" # defaults to "false", FIXME: not representable
+
+
+## serials: network, client (since vSphere 4.1) ################################
+
+->type = _CHR_TYPE_TCP <=> serial0.fileType = "network"
+
+->data.tcp.host = <host> <=> serial0.fileName = "<protocol>://<host>:<service>"
+->data.tcp.service = <service> # e.g. "telnet://192.168.0.17:42001"
+->data.tcp.protocol = <protocol>
+
+->data.tcp.listen = 0 <=> serial0.network.endPoint = "client" # defaults to "server"
+
+??? <=> serial0.vspc = "foobar" # defaults to <not present>, FIXME: not representable
+??? <=> serial0.tryNoRxLoss = "false" # defaults to "false", FIXME: not representable
+??? <=> serial0.yieldOnMsrRead = "true" # defaults to "false", FIXME: not representable
+
+
################################################################################
## parallels ###################################################################
@@ -424,8 +454,11 @@ def->parallels[0]...
#define VIR_FROM_THIS VIR_FROM_ESX
+#define ESX_BUILD_VMX_NAME_EXTRA(_suffix, _extra) \
+ snprintf(_suffix##_name, sizeof(_suffix##_name), "%s."_extra, prefix);
+
#define ESX_BUILD_VMX_NAME(_suffix) \
- snprintf(_suffix##_name, sizeof(_suffix##_name), "%s."#_suffix, prefix);
+ ESX_BUILD_VMX_NAME_EXTRA(_suffix, #_suffix)
/* directly map the virDomainControllerModel to esxVMX_SCSIControllerModel,
* this is good enough for now because all virDomainControllerModel values
@@ -2113,6 +2146,11 @@ esxVMX_ParseSerial(esxVMX_Context *ctx, virConfPtr conf, int port,
char fileName_name[48] = "";
char *fileName = NULL;
+ char network_endPoint_name[48] = "";
+ char *network_endPoint = NULL;
+
+ xmlURIPtr parsedUri = NULL;
+
if (def == NULL || *def != NULL) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
@@ -2137,6 +2175,7 @@ esxVMX_ParseSerial(esxVMX_Context *ctx, virConfPtr conf, int port,
ESX_BUILD_VMX_NAME(startConnected);
ESX_BUILD_VMX_NAME(fileType);
ESX_BUILD_VMX_NAME(fileName);
+ ESX_BUILD_VMX_NAME_EXTRA(network_endPoint, "network.endPoint");
/* vmx:present */
if (esxUtil_GetConfigBoolean(conf, present_name, &present, false,
@@ -2165,6 +2204,12 @@ esxVMX_ParseSerial(esxVMX_Context *ctx, virConfPtr conf, int port,
goto cleanup;
}
+ /* vmx:network.endPoint -> def:data.tcp.listen */
+ if (esxUtil_GetConfigString(conf, network_endPoint_name, &network_endPoint,
+ true) < 0) {
+ goto cleanup;
+ }
+
/* Setup virDomainChrDef */
if (STRCASEEQ(fileType, "device")) {
(*def)->target.port = port;
@@ -2190,10 +2235,72 @@ esxVMX_ParseSerial(esxVMX_Context *ctx, virConfPtr conf, int port,
(*def)->data.file.path = fileName;
fileName = NULL;
+ } else if (STRCASEEQ(fileType, "network")) {
+ (*def)->target.port = port;
+ (*def)->type = VIR_DOMAIN_CHR_TYPE_TCP;
+
+ parsedUri = xmlParseURI(fileName);
+
+ if (parsedUri == NULL) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ if (parsedUri->port == 0) {
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("VMX entry '%s' doesn't contain a port part"),
+ fileName_name);
+ goto cleanup;
+ }
+
+ (*def)->data.tcp.host = strdup(parsedUri->server);
+
+ if ((*def)->data.tcp.host == NULL) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ if (virAsprintf(&(*def)->data.tcp.service, "%d", parsedUri->port) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ /* See vSphere API documentation about VirtualSerialPortURIBackingInfo */
+ if (parsedUri->scheme == NULL ||
+ STRCASEEQ(parsedUri->scheme, "tcp") ||
+ STRCASEEQ(parsedUri->scheme, "tcp4") ||
+ STRCASEEQ(parsedUri->scheme, "tcp6")) {
+ (*def)->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW;
+ } else if (STRCASEEQ(parsedUri->scheme, "telnet")) {
+ (*def)->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET;
+ } else if (STRCASEEQ(parsedUri->scheme, "telnets")) {
+ (*def)->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNETS;
+ } else if (STRCASEEQ(parsedUri->scheme, "ssl") ||
+ STRCASEEQ(parsedUri->scheme, "tcp+ssl") ||
+ STRCASEEQ(parsedUri->scheme, "tcp4+ssl") ||
+ STRCASEEQ(parsedUri->scheme, "tcp6+ssl")) {
+ (*def)->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_TLS;
+ } else {
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("VMX entry '%s' contains unsupported scheme '%s'"),
+ fileName_name, parsedUri->scheme);
+ goto cleanup;
+ }
+
+ if (network_endPoint == NULL || STRCASEEQ(network_endPoint, "server")) {
+ (*def)->data.tcp.listen = 1;
+ } else if (STRCASEEQ(network_endPoint, "client")) {
+ (*def)->data.tcp.listen = 0;
+ } else {
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Expecting VMX entry '%s' to be 'server' or 'client' "
+ "but found '%s'"), network_endPoint_name, network_endPoint);
+ goto cleanup;
+ }
} else {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry '%s' to be 'device', 'file' or 'pipe' "
- "but found '%s'"), fileType_name, fileType);
+ "or 'network' but found '%s'"), fileType_name, fileType);
goto cleanup;
}
@@ -2207,6 +2314,8 @@ esxVMX_ParseSerial(esxVMX_Context *ctx, virConfPtr conf, int port,
VIR_FREE(fileType);
VIR_FREE(fileName);
+ VIR_FREE(network_endPoint);
+ xmlFreeURI(parsedUri);
return result;
@@ -3069,6 +3178,7 @@ esxVMX_FormatSerial(esxVMX_Context *ctx, virDomainChrDefPtr def,
virBufferPtr buffer)
{
char *fileName = NULL;
+ const char *protocol;
if (def->target.port < 0 || def->target.port > 3) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
@@ -3077,13 +3187,6 @@ esxVMX_FormatSerial(esxVMX_Context *ctx, virDomainChrDefPtr def,
return -1;
}
- if (def->data.file.path == NULL) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Expecting domain XML attribute 'path' of entry "
- "'devices/serial/source' to be present"));
- return -1;
- }
-
virBufferVSprintf(buffer, "serial%d.present = \"true\"\n", def->target.port);
/* def:type -> vmx:fileType and def:data.file.path -> vmx:fileName */
@@ -3124,6 +3227,41 @@ esxVMX_FormatSerial(esxVMX_Context *ctx, virDomainChrDefPtr def,
def->target.port, def->data.file.path);
break;
+ case VIR_DOMAIN_CHR_TYPE_TCP:
+ switch (def->data.tcp.protocol) {
+ case VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW:
+ protocol = "tcp";
+ break;
+
+ case VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET:
+ protocol = "telnet";
+ break;
+
+ case VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNETS:
+ protocol = "telnets";
+ break;
+
+ case VIR_DOMAIN_CHR_TCP_PROTOCOL_TLS:
+ protocol = "ssl";
+ break;
+
+ default:
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Unsupported character device TCP protocol '%s'"),
+ virDomainChrTcpProtocolTypeToString(def->data.tcp.protocol));
+ return -1;
+ }
+
+ virBufferVSprintf(buffer, "serial%d.fileType = \"network\"\n",
+ def->target.port);
+ virBufferVSprintf(buffer, "serial%d.fileName = \"%s://%s:%s\"\n",
+ def->target.port, protocol, def->data.tcp.host,
+ def->data.tcp.service);
+ virBufferVSprintf(buffer, "serial%d.network.endPoint = \"%s\"\n",
+ def->target.port,
+ def->data.tcp.listen ? "server" : "client");
+ break;
+
default:
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Unsupported character device type '%s'"),
@@ -3154,13 +3292,6 @@ esxVMX_FormatParallel(esxVMX_Context *ctx, virDomainChrDefPtr def,
return -1;
}
- if (def->data.file.path == NULL) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Expecting domain XML attribute 'path' of entry "
- "'devices/parallel/source' to be present"));
- return -1;
- }
-
virBufferVSprintf(buffer, "parallel%d.present = \"true\"\n",
def->target.port);
diff --git a/tests/vmx2xmldata/vmx2xml-serial-network-client.vmx b/tests/vmx2xmldata/vmx2xml-serial-network-client.vmx
new file mode 100644
index 0000000..18cfc57
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-serial-network-client.vmx
@@ -0,0 +1,6 @@
+config.version = "8"
+virtualHW.version = "4"
+serial0.present = "true"
+serial0.fileType = "network"
+serial0.fileName = "tcp://192.168.0.17:42001"
+serial0.network.endPoint = "client"
diff --git a/tests/vmx2xmldata/vmx2xml-serial-network-client.xml b/tests/vmx2xmldata/vmx2xml-serial-network-client.xml
new file mode 100644
index 0000000..b0c0715
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-serial-network-client.xml
@@ -0,0 +1,25 @@
+<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>
+ <serial type='tcp'>
+ <source mode='connect' host='192.168.0.17' service='42001'/>
+ <protocol type='raw'/>
+ <target port='0'/>
+ </serial>
+ <console type='tcp'>
+ <source mode='connect' host='192.168.0.17' service='42001'/>
+ <protocol type='raw'/>
+ <target type='serial' port='0'/>
+ </console>
+ </devices>
+</domain>
diff --git a/tests/vmx2xmldata/vmx2xml-serial-network-server.vmx b/tests/vmx2xmldata/vmx2xml-serial-network-server.vmx
new file mode 100644
index 0000000..d4a9c41
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-serial-network-server.vmx
@@ -0,0 +1,6 @@
+config.version = "8"
+virtualHW.version = "4"
+serial0.present = "true"
+serial0.fileType = "network"
+serial0.fileName = "telnets://0.0.0.0:42001"
+serial0.network.endPoint = "server"
diff --git a/tests/vmx2xmldata/vmx2xml-serial-network-server.xml b/tests/vmx2xmldata/vmx2xml-serial-network-server.xml
new file mode 100644
index 0000000..e151017
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-serial-network-server.xml
@@ -0,0 +1,25 @@
+<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>
+ <serial type='tcp'>
+ <source mode='bind' host='0.0.0.0' service='42001'/>
+ <protocol type='telnets'/>
+ <target port='0'/>
+ </serial>
+ <console type='tcp'>
+ <source mode='bind' host='0.0.0.0' service='42001'/>
+ <protocol type='telnets'/>
+ <target type='serial' port='0'/>
+ </console>
+ </devices>
+</domain>
diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c
index c71f536..2d59297 100644
--- a/tests/vmx2xmltest.c
+++ b/tests/vmx2xmltest.c
@@ -266,6 +266,8 @@ mymain(int argc, char **argv)
DO_TEST("serial-pipe-server-vm", "serial-pipe", esxVI_ProductVersion_ESX35);
DO_TEST("serial-pipe-client-app", "serial-pipe", esxVI_ProductVersion_ESX35);
DO_TEST("serial-pipe-server-vm", "serial-pipe", esxVI_ProductVersion_ESX35);
+ DO_TEST("serial-network-server", "serial-network-server", esxVI_ProductVersion_ESX41);
+ DO_TEST("serial-network-client", "serial-network-client", esxVI_ProductVersion_ESX41);
DO_TEST("parallel-file", "parallel-file", esxVI_ProductVersion_ESX35);
DO_TEST("parallel-device", "parallel-device", esxVI_ProductVersion_ESX35);
diff --git a/tests/xml2vmxdata/xml2vmx-serial-network-client.vmx b/tests/xml2vmxdata/xml2vmx-serial-network-client.vmx
new file mode 100644
index 0000000..d10f403
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-serial-network-client.vmx
@@ -0,0 +1,14 @@
+config.version = "8"
+virtualHW.version = "7"
+guestOS = "other"
+uuid.bios = "56 4d 9b ef ac d9 b4 e0-c8 f0 ae a8 b9 10 35 15"
+displayName = "serial-network"
+memsize = "4"
+numvcpus = "1"
+floppy0.present = "false"
+floppy1.present = "false"
+serial0.present = "true"
+serial0.fileType = "network"
+serial0.fileName = "tcp://192.168.0.17:42001"
+serial0.network.endPoint = "client"
+serial0.yieldOnMsrRead = "true"
diff --git a/tests/xml2vmxdata/xml2vmx-serial-network-client.xml b/tests/xml2vmxdata/xml2vmx-serial-network-client.xml
new file mode 100644
index 0000000..e2a5afe
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-serial-network-client.xml
@@ -0,0 +1,15 @@
+<domain type='vmware'>
+ <name>serial-network</name>
+ <uuid>564d9bef-acd9-b4e0-c8f0-aea8b9103515</uuid>
+ <memory>4096</memory>
+ <os>
+ <type>hvm</type>
+ </os>
+ <devices>
+ <serial type='tcp'>
+ <source mode="connect" host="192.168.0.17" service="42001"/>
+ <protocol type="raw"/>
+ <target port='0'/>
+ </serial>
+ </devices>
+</domain>
diff --git a/tests/xml2vmxdata/xml2vmx-serial-network-server.vmx b/tests/xml2vmxdata/xml2vmx-serial-network-server.vmx
new file mode 100644
index 0000000..b5d77f4
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-serial-network-server.vmx
@@ -0,0 +1,14 @@
+config.version = "8"
+virtualHW.version = "7"
+guestOS = "other"
+uuid.bios = "56 4d 9b ef ac d9 b4 e0-c8 f0 ae a8 b9 10 35 15"
+displayName = "serial-network"
+memsize = "4"
+numvcpus = "1"
+floppy0.present = "false"
+floppy1.present = "false"
+serial0.present = "true"
+serial0.fileType = "network"
+serial0.fileName = "ssl://0.0.0.0:42001"
+serial0.network.endPoint = "server"
+serial0.yieldOnMsrRead = "true"
diff --git a/tests/xml2vmxdata/xml2vmx-serial-network-server.xml b/tests/xml2vmxdata/xml2vmx-serial-network-server.xml
new file mode 100644
index 0000000..a17e2fe
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-serial-network-server.xml
@@ -0,0 +1,15 @@
+<domain type='vmware'>
+ <name>serial-network</name>
+ <uuid>564d9bef-acd9-b4e0-c8f0-aea8b9103515</uuid>
+ <memory>4096</memory>
+ <os>
+ <type>hvm</type>
+ </os>
+ <devices>
+ <serial type='tcp'>
+ <source mode="bind" host="0.0.0.0" service="42001"/>
+ <protocol type="tls"/>
+ <target port='0'/>
+ </serial>
+ </devices>
+</domain>
diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c
index 2a457b4..0881ae9 100644
--- a/tests/xml2vmxtest.c
+++ b/tests/xml2vmxtest.c
@@ -259,6 +259,8 @@ mymain(int argc, char **argv)
DO_TEST("serial-file", "serial-file", esxVI_ProductVersion_ESX35);
DO_TEST("serial-device", "serial-device", esxVI_ProductVersion_ESX35);
DO_TEST("serial-pipe", "serial-pipe", esxVI_ProductVersion_ESX35);
+ DO_TEST("serial-network-server", "serial-network-server", esxVI_ProductVersion_ESX41);
+ DO_TEST("serial-network-client", "serial-network-client", esxVI_ProductVersion_ESX41);
DO_TEST("parallel-file", "parallel-file", esxVI_ProductVersion_ESX35);
DO_TEST("parallel-device", "parallel-device", esxVI_ProductVersion_ESX35);
--
1.7.0.4
14 years, 2 months
[libvirt] [PATCH] phyp: Verify that domain XML contains at least one disk element
by Matthias Bolte
phypBuildLpar expects that at least one disk element is provided.
---
src/phyp/phyp_driver.c | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index ab12392..0a7d6f9 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -3715,13 +3715,17 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def)
goto err;
}
- if (def->ndisks > 0) {
- if (!def->disks[0]->src) {
- PHYP_ERROR(VIR_ERR_XML_ERROR,"%s",
- _("Field \"<src>\" under \"<disk>\" on the domain XML file is "
- "missing."));
- goto err;
- }
+ if (def->ndisks < 1) {
+ PHYP_ERROR(VIR_ERR_XML_ERROR, "%s",
+ _("Domain XML must contain at least one \"<disk>\" element."));
+ goto err;
+ }
+
+ if (!def->disks[0]->src) {
+ PHYP_ERROR(VIR_ERR_XML_ERROR,"%s",
+ _("Field \"<src>\" under \"<disk>\" on the domain XML file is "
+ "missing."));
+ goto err;
}
virBufferAddLit(&buf, "mksyscfg");
--
1.7.0.4
14 years, 2 months
[libvirt] [PATCH] PHYP: Checking for NULL values when building new guest
by Eduardo Otubo
When creating a new gust, the function phypBuildLpar() was not
checking for NULL values, making the driver to have a segmentation
fault.
---
src/phyp/phyp_driver.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 251111d..999870e 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -3701,6 +3701,25 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def)
int exit_status = 0;
virBuffer buf = VIR_BUFFER_INITIALIZER;
+ if (!def->name) {
+ VIR_ERROR0(_("Field \"<name>\" on the domain XML file missing."));
+ goto err;
+ } else if (!def->memory) {
+ VIR_ERROR0(_
+ ("Field \"<memory>\" on the domain XML file missing."));
+ goto err;
+ } else if (!def->maxmem) {
+ VIR_ERROR0(_
+ ("Field \"<currentMemory>\" on the domain XML file missing."));
+ goto err;
+ } else if (!def->vcpus) {
+ VIR_ERROR0(_("Field \"<vcpu>\" on the domain XML file missing."));
+ goto err;
+ } else if (!def->disks[0]->src) {
+ VIR_ERROR0(_("Field \"<disk>\" on the domain XML file missing."));
+ goto err;
+ }
+
virBufferAddLit(&buf, "mksyscfg");
if (system_type == HMC)
virBufferVSprintf(&buf, " -m %s", managed_system);
--
1.7.0.4
14 years, 2 months
[libvirt] Storage volume
by Jaromír Červenka
Hello,
is there any way, how to create storage volume from existing qcow2 image
file? I have XML description for this new volume and image which was used
without xml. But when I tried "vol-create" it automatically deleted this
file and created new one.
Thank you,
Jaromír Červenka
Official openSUSE community member
Web: http://www.cervajz.com/
Jabber: cervajz(a)cervajz.com
MSN: jara.cervenka(a)seznam.cz
Tel.: +420 607 592 687
Alt. e-mails:
jaromir.cervenka(a)opensuse.org,
jaromir.cervenka(a)speel.cz
14 years, 2 months
[libvirt] [PATCH] 1/1: implement usb and pci hot attach in AppArmor driver
by Jamie Strandboge
The AppArmor security driver has partial support for hostdev devices in
that if they already exist in the XML, virt-aa-helper can find them and
add them to the profile. Hot attach does not work[1] because
AppArmorSetSecurityHostdevLabel and AppArmorRestoreSecurityHostdevLabel
are not currently implemented. From the patch description:
Implement AppArmorSetSecurityHostdevLabel() and
AppArmorRestoreSecurityHostdevLabel() for hostdev and pcidev attach.
virt-aa-helper also has to be adjusted because *FileIterate() is used
for pci and usb devices and the corresponding XML for hot attached
hostdev and pcidev is not in the XML passed to virt-aa-helper. The new
'-F filename' option is added to append a rule to the profile as opposed
to the existing '-f filename', which rewrites the libvirt-<uuid>.files
file anew. This new '-F' option will append a rule to an existing
libvirt-<uuid>.files if it exists, otherwise it acts the same as '-f'.
load_profile() and reload_profile() have been adjusted to add an
'append' argument, which when true will use '-F' instead of '-f' when
executing virt-aa-helper.
All existing calls to load_profile() and reload_profile() have been
adjusted to use the old behavior (ie append==false) except
AppArmorSetSavedStateLabel() where it made sense to use the new
behavior.
This patch also adds tests for '-F'
The tests still use the old convention of cat with sed that Eric Blake
mentioned should be improved-- I will be submitting another patch for
this. This patch compiles fine with --enable-compile-warnings=error,
passes the parts of 'make check' that this patch touches (ie, the
daemon-conf fails here, but it always fails for me) and passes
'syntax-check'.
Jamie
[1]https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/640993
--
Jamie Strandboge | http://www.canonical.com
14 years, 2 months
[libvirt] [PATCH] virt-aa-helper: translate error messages
by Eric Blake
These messages are visible to the user, so they should be
consistently translated.
* cfg.mk (msg_gen_function): Add vah_error, vah_warning.
* src/security/virt-aa-helper.c: Translate messages.
(catchXMLError): Fix capitalization.
---
I noticed this sitting on one of my branches (since May!) thanks
to Jamie's recent apparmor patches. Any objections?
cfg.mk | 2 +
src/security/virt-aa-helper.c | 181 +++++++++++++++++++++--------------------
2 files changed, 95 insertions(+), 88 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index d50ffb7..fd64966 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -337,6 +337,8 @@ msg_gen_function += qemudReportError
msg_gen_function += regerror
msg_gen_function += remoteDispatchFormatError
msg_gen_function += umlReportError
+msg_gen_function += vah_error
+msg_gen_function += vah_warning
msg_gen_function += vboxError
msg_gen_function += virConfError
msg_gen_function += virDomainReportError
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index eba34b0..cc1368a 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -1,6 +1,8 @@
/*
* virt-aa-helper: wrapper program used by AppArmor security driver.
+ *
+ * Copyright (C) 2010 Red Hat, Inc.
* Copyright (C) 2009-2010 Canonical Ltd.
*
* See COPYING.LIB for the License of this software
@@ -80,28 +82,28 @@ vahDeinit(vahControl * ctl)
static void
vah_usage(void)
{
- fprintf(stdout, "\n%s [options] [< def.xml]\n\n"
- " Options:\n"
- " -a | --add load profile\n"
- " -c | --create create profile from template\n"
- " -D | --delete unload and delete profile\n"
- " -f | --add-file <file> add file to profile\n"
- " -F | --append-file <file> append file to profile\n"
- " -r | --replace reload profile\n"
- " -R | --remove unload profile\n"
- " -h | --help this help\n"
- " -u | --uuid <uuid> uuid (profile name)\n"
- "\n", progname);
-
- fprintf(stdout, "This command is intended to be used by libvirtd "
- "and not used directly.\n");
+ fprintf(stdout, _("\n%s [options] [< def.xml]\n\n
+ Options:\n
+ -a | --add load profile\n
+ -c | --create create profile from template\n
+ -D | --delete unload and delete profile\n
+ -f | --add-file <file> add file to profile\n
+ -F | --append-file <file> append file to profile\n
+ -r | --replace reload profile\n
+ -R | --remove unload profile\n
+ -h | --help this help\n
+ -u | --uuid <uuid> uuid (profile name)\n
+\n", progname);
+
+ fputs(_("This command is intended to be used by libvirtd "
+ "and not used directly.\n"));
return;
}
static void
vah_error(vahControl * ctl, int doexit, const char *str)
{
- fprintf(stderr, _("%s: error: %s\n"), progname, str);
+ fprintf(stderr, _("%s: error: %s%c"), progname, str, '\n');
if (doexit) {
if (ctl != NULL)
@@ -113,13 +115,13 @@ vah_error(vahControl * ctl, int doexit, const char *str)
static void
vah_warning(const char *str)
{
- fprintf(stderr, _("%s: warning: %s\n"), progname, str);
+ fprintf(stderr, _("%s: warning: %s%c"), progname, str, '\n');
}
static void
vah_info(const char *str)
{
- fprintf(stderr, _("%s:\n%s\n"), progname, str);
+ fprintf(stderr, _("%s:\n%s%c"), progname, str, '\n');
}
/*
@@ -136,12 +138,12 @@ replace_string(char *orig, const size_t len, const char *oldstr,
char *tmp = NULL;
if ((pos = strstr(orig, oldstr)) == NULL) {
- vah_error(NULL, 0, "could not find replacement string");
+ vah_error(NULL, 0, _("could not find replacement string"));
return -1;
}
if (VIR_ALLOC_N(tmp, len) < 0) {
- vah_error(NULL, 0, "could not allocate memory for string");
+ vah_error(NULL, 0, _("could not allocate memory for string"));
return -1;
}
tmp[0] = '\0';
@@ -153,7 +155,7 @@ replace_string(char *orig, const size_t len, const char *oldstr,
/* add the replacement string */
if (strlen(tmp) + strlen(repstr) > len - 1) {
- vah_error(NULL, 0, "not enough space in target buffer");
+ vah_error(NULL, 0, _("not enough space in target buffer"));
VIR_FREE(tmp);
return -1;
}
@@ -161,7 +163,7 @@ replace_string(char *orig, const size_t len, const char *oldstr,
/* add everything after oldstr */
if (strlen(tmp) + strlen(orig) - (idx + strlen(oldstr)) > len - 1) {
- vah_error(NULL, 0, "not enough space in target buffer");
+ vah_error(NULL, 0, _("not enough space in target buffer"));
VIR_FREE(tmp);
return -1;
}
@@ -169,7 +171,7 @@ replace_string(char *orig, const size_t len, const char *oldstr,
strlen(orig) - (idx + strlen(oldstr)));
if (virStrcpy(orig, tmp, len) == NULL) {
- vah_error(NULL, 0, "error replacing string");
+ vah_error(NULL, 0, _("error replacing string"));
VIR_FREE(tmp);
return -1;
}
@@ -190,7 +192,7 @@ parserCommand(const char *profile_name, const char cmd)
int ret;
if (strchr("arR", cmd) == NULL) {
- vah_error(NULL, 0, "invalid flag");
+ vah_error(NULL, 0, _("invalid flag"));
return -1;
}
@@ -198,12 +200,12 @@ parserCommand(const char *profile_name, const char cmd)
if (snprintf(profile, PATH_MAX, "%s/%s",
APPARMOR_DIR "/libvirt", profile_name) > PATH_MAX - 1) {
- vah_error(NULL, 0, "profile name exceeds maximum length");
+ vah_error(NULL, 0, _("profile name exceeds maximum length"));
return -1;
}
if (!virFileExists(profile)) {
- vah_error(NULL, 0, "profile does not exist");
+ vah_error(NULL, 0, _("profile does not exist"));
return -1;
} else {
const char * const argv[] = {
@@ -212,12 +214,13 @@ parserCommand(const char *profile_name, const char cmd)
if ((ret = virRun(argv, &status)) != 0 ||
(WIFEXITED(status) && WEXITSTATUS(status) != 0)) {
if (ret != 0) {
- vah_error(NULL, 0, "failed to run apparmor_parser");
+ vah_error(NULL, 0, _("failed to run apparmor_parser"));
return -1;
- } else if (cmd == 'R' && WIFEXITED(status) && WEXITSTATUS(status) == 234) {
- vah_warning("unable to unload already unloaded profile (non-fatal)");
+ } else if (cmd == 'R' && WIFEXITED(status) &&
+ WEXITSTATUS(status) == 234) {
+ vah_warning(_("unable to unload already unloaded profile"));
} else {
- vah_error(NULL, 0, "apparmor_parser exited with error");
+ vah_error(NULL, 0, _("apparmor_parser exited with error"));
return -1;
}
}
@@ -249,19 +252,19 @@ update_include_file(const char *include_file, const char *included_files,
if (append && virFileExists(include_file)) {
if (virAsprintf(&pcontent, "%s%s", existing, included_files) == -1) {
- vah_error(NULL, 0, "could not allocate memory for profile");
+ vah_error(NULL, 0, _("could not allocate memory for profile"));
goto clean;
}
} else {
if (virAsprintf(&pcontent, "%s%s", warning, included_files) == -1) {
- vah_error(NULL, 0, "could not allocate memory for profile");
+ vah_error(NULL, 0, _("could not allocate memory for profile"));
goto clean;
}
}
plen = strlen(pcontent);
if (plen > MAX_FILE_LEN) {
- vah_error(NULL, 0, "invalid length for new profile");
+ vah_error(NULL, 0, _("invalid length for new profile"));
goto clean;
}
@@ -273,18 +276,18 @@ update_include_file(const char *include_file, const char *included_files,
/* write the file */
if ((fd = open(include_file, O_CREAT | O_TRUNC | O_WRONLY, 0644)) == -1) {
- vah_error(NULL, 0, "failed to create include file");
+ vah_error(NULL, 0, _("failed to create include file"));
goto clean;
}
if (safewrite(fd, pcontent, plen) < 0) { /* don't write the '\0' */
close(fd);
- vah_error(NULL, 0, "failed to write to profile");
+ vah_error(NULL, 0, _("failed to write to profile"));
goto clean;
}
if (close(fd) != 0) {
- vah_error(NULL, 0, "failed to close or write to profile");
+ vah_error(NULL, 0, _("failed to close or write to profile"));
goto clean;
}
rc = 0;
@@ -315,45 +318,45 @@ create_profile(const char *profile, const char *profile_name,
int rc = -1;
if (virFileExists(profile)) {
- vah_error(NULL, 0, "profile exists");
+ vah_error(NULL, 0, _("profile exists"));
goto end;
}
if (snprintf(template, PATH_MAX, "%s/TEMPLATE",
APPARMOR_DIR "/libvirt") > PATH_MAX - 1) {
- vah_error(NULL, 0, "template name exceeds maximum length");
+ vah_error(NULL, 0, _("template name exceeds maximum length"));
goto end;
}
if (!virFileExists(template)) {
- vah_error(NULL, 0, "template does not exist");
+ vah_error(NULL, 0, _("template does not exist"));
goto end;
}
if ((tlen = virFileReadAll(template, MAX_FILE_LEN, &tcontent)) < 0) {
- vah_error(NULL, 0, "failed to read AppArmor template");
+ vah_error(NULL, 0, _("failed to read AppArmor template"));
goto end;
}
if (strstr(tcontent, template_name) == NULL) {
- vah_error(NULL, 0, "no replacement string in template");
+ vah_error(NULL, 0, _("no replacement string in template"));
goto clean_tcontent;
}
if (strstr(tcontent, template_end) == NULL) {
- vah_error(NULL, 0, "no replacement string in template");
+ vah_error(NULL, 0, _("no replacement string in template"));
goto clean_tcontent;
}
/* '\nprofile <profile_name>\0' */
if (virAsprintf(&replace_name, "\nprofile %s", profile_name) == -1) {
- vah_error(NULL, 0, "could not allocate memory for profile name");
+ vah_error(NULL, 0, _("could not allocate memory for profile name"));
goto clean_tcontent;
}
/* '\n<profile_files>\n}\0' */
if (virAsprintf(&replace_files, "\n%s\n}", profile_files) == -1) {
- vah_error(NULL, 0, "could not allocate memory for profile files");
+ vah_error(NULL, 0, _("could not allocate memory for profile files"));
VIR_FREE(replace_name);
goto clean_tcontent;
}
@@ -361,12 +364,12 @@ create_profile(const char *profile, const char *profile_name,
plen = tlen + strlen(replace_name) - strlen(template_name) +
strlen(replace_files) - strlen(template_end) + 1;
if (plen > MAX_FILE_LEN || plen < tlen) {
- vah_error(NULL, 0, "invalid length for new profile");
+ vah_error(NULL, 0, _("invalid length for new profile"));
goto clean_replace;
}
if (VIR_ALLOC_N(pcontent, plen) < 0) {
- vah_error(NULL, 0, "could not allocate memory for profile");
+ vah_error(NULL, 0, _("could not allocate memory for profile"));
goto clean_replace;
}
pcontent[0] = '\0';
@@ -380,18 +383,18 @@ create_profile(const char *profile, const char *profile_name,
/* write the file */
if ((fd = open(profile, O_CREAT | O_EXCL | O_WRONLY, 0644)) == -1) {
- vah_error(NULL, 0, "failed to create profile");
+ vah_error(NULL, 0, _("failed to create profile"));
goto clean_all;
}
if (safewrite(fd, pcontent, plen - 1) < 0) { /* don't write the '\0' */
close(fd);
- vah_error(NULL, 0, "failed to write to profile");
+ vah_error(NULL, 0, _("failed to write to profile"));
goto clean_all;
}
if (close(fd) != 0) {
- vah_error(NULL, 0, "failed to close or write to profile");
+ vah_error(NULL, 0, _("failed to close or write to profile"));
goto clean_all;
}
rc = 0;
@@ -530,7 +533,7 @@ valid_path(const char *path, const bool readonly)
};
if (path == NULL || strlen(path) > PATH_MAX - 1) {
- vah_error(NULL, 0, "bad pathname");
+ vah_error(NULL, 0, _("bad pathname"));
return -1;
}
@@ -545,7 +548,7 @@ valid_path(const char *path, const bool readonly)
return 1;
if (!virFileExists(path))
- vah_warning("path does not exist, skipping file type checks");
+ vah_warning(_("path does not exist, skipping file type checks"));
else {
if (stat(path, &sb) == -1)
return -1;
@@ -595,7 +598,7 @@ catchXMLError (void *ctx, const char *msg ATTRIBUTE_UNUSED, ...)
if (virAsprintf(&err_str, "XML error at line %d: %s",
ctxt->lastError.line,
ctxt->lastError.message) == -1)
- vah_error(NULL, 0, "Could not get XML error");
+ vah_error(NULL, 0, _("could not get XML error"));
else {
vah_error(NULL, 0, err_str);
VIR_FREE(err_str);
@@ -632,29 +635,29 @@ caps_mockup(vahControl * ctl, const char *xmlStr)
XML_PARSE_NOWARNING);
if (!xml) {
if (virGetLastError() == NULL)
- vah_error(NULL, 0, "failed to parse xml document");
+ vah_error(NULL, 0, _("failed to parse xml document"));
goto cleanup;
}
if ((root = xmlDocGetRootElement(xml)) == NULL) {
- vah_error(NULL, 0, "missing root element");
+ vah_error(NULL, 0, _("missing root element"));
goto cleanup;
}
if (!xmlStrEqual(root->name, BAD_CAST "domain")) {
- vah_error(NULL, 0, "incorrect root element");
+ vah_error(NULL, 0, _("incorrect root element"));
goto cleanup;
}
if ((ctxt = xmlXPathNewContext(xml)) == NULL) {
- vah_error(ctl, 0, "could not allocate memory");
+ vah_error(ctl, 0, _("could not allocate memory"));
goto cleanup;
}
ctxt->node = root;
ctl->hvm = virXPathString("string(./os/type[1])", ctxt);
if (!ctl->hvm || STRNEQ(ctl->hvm, "hvm")) {
- vah_error(ctl, 0, "os.type is not 'hvm'");
+ vah_error(ctl, 0, _("os.type is not 'hvm'"));
goto cleanup;
}
ctl->arch = virXPathString("string(./os/type[1]/@arch)", ctxt);
@@ -667,7 +670,7 @@ caps_mockup(vahControl * ctl, const char *xmlStr)
/* Really, this never fails - look at the man-page. */
uname (&utsname);
if ((ctl->arch = strdup(utsname.machine)) == NULL) {
- vah_error(ctl, 0, "could not allocate memory");
+ vah_error(ctl, 0, _("could not allocate memory"));
goto cleanup;
}
}
@@ -700,7 +703,7 @@ get_definition(vahControl * ctl, const char *xmlStr)
goto exit;
if ((ctl->caps = virCapabilitiesNew(ctl->arch, 1, 1)) == NULL) {
- vah_error(ctl, 0, "could not allocate memory");
+ vah_error(ctl, 0, _("could not allocate memory"));
goto exit;
}
@@ -712,24 +715,24 @@ get_definition(vahControl * ctl, const char *xmlStr)
NULL,
0,
NULL)) == NULL) {
- vah_error(ctl, 0, "could not allocate memory");
+ vah_error(ctl, 0, _("could not allocate memory"));
goto exit;
}
ctl->def = virDomainDefParseString(ctl->caps, xmlStr,
VIR_DOMAIN_XML_INACTIVE);
if (ctl->def == NULL) {
- vah_error(ctl, 0, "could not parse XML");
+ vah_error(ctl, 0, _("could not parse XML"));
goto exit;
}
if (!ctl->def->name) {
- vah_error(ctl, 0, "could not find name in XML");
+ vah_error(ctl, 0, _("could not find name in XML"));
goto exit;
}
if (valid_name(ctl->def->name) != 0) {
- vah_error(ctl, 0, "bad name");
+ vah_error(ctl, 0, _("bad name"));
goto exit;
}
@@ -755,14 +758,14 @@ vah_add_file(virBufferPtr buf, const char *path, const char *perms)
*/
if (STRNEQLEN(path, "/", 1)) {
vah_warning(path);
- vah_warning(" skipped non-absolute path");
+ vah_warning(_(" skipped non-absolute path"));
return 0;
}
if (virFileExists(path)) {
if ((tmp = realpath(path, NULL)) == NULL) {
vah_error(NULL, 0, path);
- vah_error(NULL, 0, " could not find realpath for disk");
+ vah_error(NULL, 0, _(" could not find realpath for disk"));
return rc;
}
} else
@@ -776,7 +779,7 @@ vah_add_file(virBufferPtr buf, const char *path, const char *perms)
if (rc != 0) {
if (rc > 0) {
vah_error(NULL, 0, path);
- vah_error(NULL, 0, " skipped restricted file");
+ vah_error(NULL, 0, _(" skipped restricted file"));
}
goto clean;
}
@@ -846,12 +849,12 @@ get_files(vahControl * ctl)
/* verify uuid is same as what we were given on the command line */
virUUIDFormat(ctl->def->uuid, uuidstr);
if (virAsprintf(&uuid, "%s%s", AA_PREFIX, uuidstr) == -1) {
- vah_error(ctl, 0, "could not allocate memory");
+ vah_error(ctl, 0, _("could not allocate memory"));
return rc;
}
if (STRNEQ(uuid, ctl->uuid)) {
- vah_error(ctl, 0, "given uuid does not match XML uuid");
+ vah_error(ctl, 0, _("given uuid does not match XML uuid"));
goto clean;
}
@@ -972,7 +975,7 @@ get_files(vahControl * ctl)
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
- vah_error(NULL, 0, "failed to allocate file buffer");
+ vah_error(NULL, 0, _("failed to allocate file buffer"));
goto clean;
}
@@ -1021,7 +1024,7 @@ vahParseArgv(vahControl * ctl, int argc, char **argv)
case 'f':
case 'F':
if ((ctl->newfile = strdup(optarg)) == NULL)
- vah_error(ctl, 1, "could not allocate memory for disk");
+ vah_error(ctl, 1, _("could not allocate memory for disk")_;
ctl->append = arg == 'F';
break;
case 'h':
@@ -1036,10 +1039,10 @@ vahParseArgv(vahControl * ctl, int argc, char **argv)
break;
case 'u':
if (strlen(optarg) > PROFILE_NAME_SIZE - 1)
- vah_error(ctl, 1, "invalid UUID");
+ vah_error(ctl, 1, _("invalid UUID"));
if (virStrcpy((char *) ctl->uuid, optarg,
PROFILE_NAME_SIZE) == NULL)
- vah_error(ctl, 1, "error copying UUID");
+ vah_error(ctl, 1, _("error copying UUID"));
break;
case 'p':
if (STREQ(optarg, "1"))
@@ -1048,15 +1051,15 @@ vahParseArgv(vahControl * ctl, int argc, char **argv)
ctl->allowDiskFormatProbing = false;
break;
default:
- vah_error(ctl, 1, "unsupported option");
+ vah_error(ctl, 1, _("unsupported option"));
break;
}
}
if (strchr("acDrR", ctl->cmd) == NULL)
- vah_error(ctl, 1, "bad command");
+ vah_error(ctl, 1, _("bad command"));
if (valid_uuid(ctl->uuid) != 0)
- vah_error(ctl, 1, "invalid UUID");
+ vah_error(ctl, 1, _("invalid UUID"));
if (!ctl->cmd) {
vah_usage();
@@ -1066,16 +1069,16 @@ vahParseArgv(vahControl * ctl, int argc, char **argv)
if (ctl->cmd == 'c' || ctl->cmd == 'r') {
char *xmlStr = NULL;
if (virFileReadLimFD(STDIN_FILENO, MAX_FILE_LEN, &xmlStr) < 0)
- vah_error(ctl, 1, "could not read xml file");
+ vah_error(ctl, 1, _("could not read xml file"));
if (get_definition(ctl, xmlStr) != 0 || ctl->def == NULL) {
VIR_FREE(xmlStr);
- vah_error(ctl, 1, "could not get VM definition");
+ vah_error(ctl, 1, _("could not get VM definition"));
}
VIR_FREE(xmlStr);
if (get_files(ctl) != 0)
- vah_error(ctl, 1, "invalid VM definition");
+ vah_error(ctl, 1, _("invalid VM definition"));
}
return 0;
}
@@ -1100,10 +1103,11 @@ main(int argc, char **argv)
/* clear the environment */
environ = NULL;
if (setenv("PATH", "/sbin:/usr/sbin", 1) != 0) {
- vah_error(ctl, 1, "could not set PATH");
+ vah_error(ctl, 1, _("could not set PATH"));
}
+
if (setenv("IFS", " \t\n", 1) != 0) {
- vah_error(ctl, 1, "could not set IFS");
+ vah_error(ctl, 1, _("could not set IFS"));
}
if (!(progname = strrchr(argv[0], '/')))
@@ -1114,15 +1118,15 @@ main(int argc, char **argv)
memset(ctl, 0, sizeof(vahControl));
if (vahParseArgv(ctl, argc, argv) != 0)
- vah_error(ctl, 1, "could not parse arguments");
+ vah_error(ctl, 1, _("could not parse arguments"));
if (snprintf(profile, PATH_MAX, "%s/%s",
APPARMOR_DIR "/libvirt", ctl->uuid) > PATH_MAX - 1)
- vah_error(ctl, 1, "profile name exceeds maximum length");
+ vah_error(ctl, 1, _("profile name exceeds maximum length"));
if (snprintf(include_file, PATH_MAX, "%s/%s.files",
APPARMOR_DIR "/libvirt", ctl->uuid) > PATH_MAX - 1)
- vah_error(ctl, 1, "disk profile name exceeds maximum length");
+ vah_error(ctl, 1, _("disk profile name exceeds maximum length"));
if (ctl->cmd == 'a')
rc = parserLoad(ctl->uuid);
@@ -1135,8 +1139,9 @@ main(int argc, char **argv)
} else if (ctl->cmd == 'c' || ctl->cmd == 'r') {
char *included_files = NULL;
- if (ctl->cmd == 'c' && virFileExists(profile))
- vah_error(ctl, 1, "profile exists");
+ if (ctl->cmd == 'c' && virFileExists(profile)) {
+ vah_error(ctl, 1, _("profile exists"));
+ }
if (ctl->append && ctl->newfile) {
if (vah_add_file(&buf, ctl->newfile, "rw") != 0)
@@ -1154,7 +1159,7 @@ main(int argc, char **argv)
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
- vah_error(ctl, 1, "failed to allocate buffer");
+ vah_error(ctl, 1, _("failed to allocate buffer"));
}
included_files = virBufferContentAndReset(&buf);
@@ -1175,7 +1180,7 @@ main(int argc, char **argv)
char *tmp = NULL;
if (virAsprintf(&tmp, " #include <libvirt/%s.files>\n",
ctl->uuid) == -1) {
- vah_error(ctl, 0, "could not allocate memory");
+ vah_error(ctl, 0, _("could not allocate memory"));
goto clean;
}
@@ -1185,7 +1190,7 @@ main(int argc, char **argv)
vah_info(tmp);
rc = 0;
} else if ((rc = create_profile(profile, ctl->uuid, tmp)) != 0) {
- vah_error(ctl, 0, "could not create profile");
+ vah_error(ctl, 0, _("could not create profile"));
unlink(include_file);
}
VIR_FREE(tmp);
--
1.7.2.3
14 years, 2 months
[libvirt] [Patch v3 0/5] nwfilter: Support comment attribute in filter rule descriptions
by Stefan Berger
V3:
- moved MAX_COMMENT_LENGTH #define into include file (1/5)
- renamed IPTABLES_MAX_COMMENT_SIZE to IPTABLES_MAX_COMMENT_LENGTH (2/5)
- removal of regex from string patter in schema for comment attribute (3/5)
- added libvirt version since when comment attribute is available (4/5)
- added test cases (5/5)
V2:
- work on the iptables instantiation patch (2/5)
- work on the parser patch (1/5)
- small changes to the test cases (5/5)
The following patch series adds support for a comment node to the XML
attributes of all protocols. If possible, as for example in case of iptables,
the comments are instantiated (iptables ... -m comment --comment ...).
The patches do the following:
- extend the parser and XML generator to parse and create XML with the
comment attribute
- instantiate the comment in case of ip(6)tables
- extend the nwfilter.rng schema with the comment attribute
- add the information to the web docs
- add a test case for the XML parser/generator to be run during 'make check'
Regards,
Stefan
14 years, 2 months