[libvirt] OpenVZ : cannot assign bridge to any interface
by Yuji NISHIDA
Hi,
I'm bit confuing between 2 problems with libvirt-0.6.5 for OpenVZ.
[1] bridge was created but no interface assigned to it
[2] virsh dumpxml returns xml in which type is "qemu"
[1] -------------------------------------------------
I tried libvirt-0.6.5 on Fedora8 to create OpenVZ container ( OpenVZ
kernel is linux-2.6.18 ).
A bridge was seemed to successfully create but no interface could not
be assigned to the bridge.
Due to that, ping could not reach the guest in container(10.0.1.2).
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
[root@node13 test]# brctl show
bridge name bridge id STP enabled interfaces
br101 8000.000000000000 no
[root@node13 test]# ifconfig -a
br101 Link encap:Ethernet HWaddr 00:00:00:00:00:00
inet addr:10.0.1.1 Bcast:10.0.1.15 Mask:255.255.255.240
inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:5031 (4.9 KiB)
eth0 Link encap:Ethernet HWaddr 00:1C:C4:xx:xx:xx
inet addr:133.xx.xx.xx Bcast:133.xx.xx.xx Mask:255.255.255.0
inet6 addr: fe80::21c:c4ff:xxxx:xxxx/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:196949 errors:0 dropped:0 overruns:0 frame:0
TX packets:64300 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:228373526 (217.7 MiB) TX bytes:5652593 (5.3 MiB)
Interrupt:169
eth1 Link encap:Ethernet HWaddr 00:1C:C4:xx:xx:xx
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:50
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:323 errors:0 dropped:0 overruns:0 frame:0
TX packets:323 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:29949 (29.2 KiB) TX bytes:29949 (29.2 KiB)
sit0 Link encap:IPv6-in-IPv4
NOARP MTU:1480 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
venet0 Link encap:UNSPEC HWaddr
00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
veth101 Link encap:Ethernet HWaddr 52:54:00:52:C3:FF
inet6 addr: fe80::5054:ff:fe52:c3ff/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
The followings are python script and xml that I tested with.
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
[root@node13 test]# cat test.py
import libvirt
conn = libvirt.open('openvz:///system')
conn.networkDefineXML( file('net.xml').read() )
conn.defineXML( file('test.xml').read() )
net = conn.networkLookupByName('guestnet101')
net.create()
guest = conn.lookupByName('101')
guest.create()
[root@node13 test]# cat test.xml
<domain type='openvz' id='101'>
<name>101</name>
<os>
<type>exe</type>
<init>/sbin/fakeinit.sh</init>
</os>
<memory>524288</memory>
<devices>
<filesystem type='template'>
<source name='fedora-10-x86_64'/>
<target dir='/'/>
</filesystem>
<console type='pty'/>
<interface type='bridge'>
<mac address="52:54:00:00:01:01" />
<source bridge='guestnet101'/>
<target dev='veth101'/>
</interface>
</devices>
</domain>
[root@node13 test]# cat net.xml
<network>
<name>guestnet101</name>
<bridge name="br101" stp="off" />
<forward mode="nat"/>
<ip address="10.0.1.1" netmask="255.255.255.240">
<dhcp>
<range start="10.0.1.2" end="10.0.1.2" />
</dhcp>
</ip>
</network>
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
[2] -------------------------------------------------
I guess "type" in domain must be 'openvz' but virsh dumpxml returns it
as 'qemu'.
( The configuration of VE 101 remains in [1] )
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
[root@node13 test]# virsh dumpxml 101
<domain type='qemu' id='101'>
<name>101</name>
<uuid>dedee02b-b74f-6e43-f5ec-27050986efa8</uuid>
<memory>0</memory>
<currentMemory>0</currentMemory>
<vcpu>1</vcpu>
<os>
<type>exe</type>
<init>/sbin/init</init>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>destroy</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<filesystem type='template'>
<source name='fedora-10-x86_64'/>
<target dir='/'/>
</filesystem>
<interface type='bridge'>
<mac address='52:54:00:00:01:01'/>
<source bridge='guestnet101'/>
<target dev='veth101'/>
</interface>
</devices>
</domain>
[root@node13 test]# virsh net-dumpxml guestnet101
<network>
<name>guestnet101</name>
<uuid>5462e7a5-2048-3067-af9d-b134381a3f8a</uuid>
<forward mode='nat'/>
<bridge name='br101' stp='off' forwardDelay='0' />
<ip address='10.0.1.1' netmask='255.255.255.240'>
<dhcp>
<range start='10.0.1.2' end='10.0.1.2' />
</dhcp>
</ip>
</network>
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Regards.
-----
Yuji Nishida
nishidy(a)nict.go.jp
15 years, 4 months
[libvirt] How to call QEMU with -snapshot ?
by Jun Koi
Hi,
I want to execute qemu (actually is KVM, qemu-system_x86-64) with
-snapshot. Is there any way to do that?
I tried following ways, and none works:
- Put -snapshot in <emulator> in configuration file.
- Create a script calling "qemu -snapshot", and rename it to
qemu-system_x86-64 (and of course i rename the original one to smt
else, and let my scrip call that)
In all these cases, I got error about parsing for QEMU version.
Thanks,
J
15 years, 4 months
Re: [libvirt] [PATCH 9/9] Add support for qcow encrypted volumes to qemu.
by Miloslav Trmac
----- "Daniel P. Berrange" <berrange(a)redhat.com> wrote:
> On Tue, Jul 21, 2009 at 01:12:05PM +0200, Miloslav Trma?? wrote:
> > ---
> > src/qemu_driver.c | 51
> ++++++++++++++++++++++++++++++++++++++++++++++++++-
> > 1 files changed, 50 insertions(+), 1 deletions(-)
>
> IIUC this should only be needed when starting a QEMU guest.
>
> The 'cont' method is called from quite a few different contexts.
> So it might be nice to pass a flag down from qemudStartVMDaemon
> such that the passphrase handling is guarenteed to only be run
> during startup (qemudStartVMDaemon is also used for migrate
> and restore, so covers those scenarios OK)
qemudStartVMDaemon is called during migration (and restore), but it does not sent "cont".
The only place where "cont" is sent where passphrase handling is not necessary is qemudDomainResume. In any case, the passphrase handling only does something if qemu prompts for a passphrase, it does not hurt anything in other cases - on the contrary, should something go wrong and qemu would prompt for a passphrase, this ensures libvirt either supplies a passphrase, or reports an error, instead of hanging.
Mirek
15 years, 4 months
[libvirt] [PATCH] Add bare %s format string to printf-derivatives called with no format string
by Laine Stump
---
src/datatypes.c | 24 ++++++++++++------------
src/domain_conf.c | 9 +++++----
src/interface_conf.c | 4 ++--
src/lxc_driver.c | 2 +-
src/qemu_driver.c | 4 ++--
src/storage_backend.c | 6 +++---
src/virsh.c | 4 ++--
7 files changed, 27 insertions(+), 26 deletions(-)
diff --git a/src/datatypes.c b/src/datatypes.c
index 1e33ccb..8b3f8c3 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -289,7 +289,7 @@ virGetDomain(virConnectPtr conn, const char *name, const unsigned char *uuid) {
if (virHashAddEntry(conn->domains, name, ret) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
- _("failed to add domain to connection hash table"));
+ "%s", _("failed to add domain to connection hash table"));
goto error;
}
conn->refs++;
@@ -330,7 +330,7 @@ virReleaseDomain(virDomainPtr domain) {
if (virHashRemoveEntry(conn->domains, domain->name, NULL) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
- _("domain missing from connection hash table"));
+ "%s", _("domain missing from connection hash table"));
conn = NULL;
}
@@ -430,7 +430,7 @@ virGetNetwork(virConnectPtr conn, const char *name, const unsigned char *uuid) {
if (virHashAddEntry(conn->networks, name, ret) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
- _("failed to add network to connection hash table"));
+ "%s", _("failed to add network to connection hash table"));
goto error;
}
conn->refs++;
@@ -468,7 +468,7 @@ virReleaseNetwork(virNetworkPtr network) {
if (virHashRemoveEntry(conn->networks, network->name, NULL) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
- _("network missing from connection hash table"));
+ "%s", _("network missing from connection hash table"));
conn = NULL;
}
@@ -603,7 +603,7 @@ _("Failed to change interface mac address from %s to %s due to differing lengths
if (virHashAddEntry(conn->interfaces, name, ret) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
- _("failed to add interface to connection hash table"));
+ "%s", _("failed to add interface to connection hash table"));
goto error;
}
conn->refs++;
@@ -642,7 +642,7 @@ virReleaseInterface(virInterfacePtr iface) {
/* unlock before reporting error because error report grabs lock */
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
- _("interface missing from connection hash table"));
+ "%s", _("interface missing from connection hash table"));
/* don't decr the conn refct if we weren't connected to it */
conn = NULL;
}
@@ -744,7 +744,7 @@ virGetStoragePool(virConnectPtr conn, const char *name, const unsigned char *uui
if (virHashAddEntry(conn->storagePools, name, ret) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
- _("failed to add storage pool to connection hash table"));
+ "%s", _("failed to add storage pool to connection hash table"));
goto error;
}
conn->refs++;
@@ -783,7 +783,7 @@ virReleaseStoragePool(virStoragePoolPtr pool) {
if (virHashRemoveEntry(conn->storagePools, pool->name, NULL) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
- _("pool missing from connection hash table"));
+ "%s", _("pool missing from connection hash table"));
conn = NULL;
}
@@ -887,7 +887,7 @@ virGetStorageVol(virConnectPtr conn, const char *pool, const char *name, const c
if (virHashAddEntry(conn->storageVols, key, ret) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
- _("failed to add storage vol to connection hash table"));
+ "%s", _("failed to add storage vol to connection hash table"));
goto error;
}
conn->refs++;
@@ -927,7 +927,7 @@ virReleaseStorageVol(virStorageVolPtr vol) {
if (virHashRemoveEntry(conn->storageVols, vol->key, NULL) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
- _("vol missing from connection hash table"));
+ "%s", _("vol missing from connection hash table"));
conn = NULL;
}
@@ -1023,7 +1023,7 @@ virGetNodeDevice(virConnectPtr conn, const char *name)
if (virHashAddEntry(conn->nodeDevices, name, ret) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
- _("failed to add node dev to conn hash table"));
+ "%s", _("failed to add node dev to conn hash table"));
goto error;
}
conn->refs++;
@@ -1061,7 +1061,7 @@ virReleaseNodeDevice(virNodeDevicePtr dev) {
if (virHashRemoveEntry(conn->nodeDevices, dev->name, NULL) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
- _("dev missing from connection hash table"));
+ "%s", _("dev missing from connection hash table"));
conn = NULL;
}
diff --git a/src/domain_conf.c b/src/domain_conf.c
index fbe9d78..96cadd5 100644
--- a/src/domain_conf.c
+++ b/src/domain_conf.c
@@ -2189,7 +2189,7 @@ virSecurityLabelDefParseXML(virConnectPtr conn,
VIR_FREE(p);
if (def->seclabel.type < 0) {
virDomainReportError(conn, VIR_ERR_XML_ERROR,
- _("invalid security type"));
+ "%s", _("invalid security type"));
goto error;
}
@@ -2211,7 +2211,7 @@ virSecurityLabelDefParseXML(virConnectPtr conn,
VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
if (p == NULL) {
virDomainReportError(conn, VIR_ERR_XML_ERROR,
- _("security label is missing"));
+ "%s", _("security label is missing"));
goto error;
}
@@ -2224,8 +2224,9 @@ virSecurityLabelDefParseXML(virConnectPtr conn,
p = virXPathStringLimit(conn, "string(./seclabel/imagelabel[1])",
VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
if (p == NULL) {
- virDomainReportError(conn, VIR_ERR_XML_ERROR,
- _("security imagelabel is missing"));
+
+virDomainReportError(conn, VIR_ERR_XML_ERROR,
+ "%s", _("security imagelabel is missing"));
goto error;
}
def->seclabel.imagelabel = p;
diff --git a/src/interface_conf.c b/src/interface_conf.c
index 7da1a2f..a74d17e 100644
--- a/src/interface_conf.c
+++ b/src/interface_conf.c
@@ -601,7 +601,7 @@ virInterfaceDefParseXML(virConnectPtr conn, xmlXPathContextPtr ctxt) {
tmp = virXPathString(conn, "string(./@type)", ctxt);
if (tmp == NULL) {
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
- _("interface misses the type attribute"));
+ "%s", _("interface misses the type attribute"));
return(NULL);
}
type = virInterfaceTypeFromString(tmp);
@@ -643,7 +643,7 @@ virInterfaceDefParseXML(virConnectPtr conn, xmlXPathContextPtr ctxt) {
bridge = virXPathNode(conn, "./bridge[1]", ctxt);
if (bridge == NULL) {
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
- _("bridge interface misses the bridge element"));
+ "%s", _("bridge interface misses the bridge element"));
goto error;
}
tmp = virXMLPropString(bridge, "stp");
diff --git a/src/lxc_driver.c b/src/lxc_driver.c
index 3503573..66cfa8e 100644
--- a/src/lxc_driver.c
+++ b/src/lxc_driver.c
@@ -102,7 +102,7 @@ static virDrvOpenStatus lxcOpen(virConnectPtr conn,
/* URI was good, but driver isn't active */
if (lxc_driver == NULL) {
lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR,
- _("lxc state driver is not active"));
+ "%s", _("lxc state driver is not active"));
return VIR_DRV_OPEN_ERROR;
}
}
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index c4683ae..3b56092 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -1599,7 +1599,7 @@ static int qemudSecurityHook(void *data) {
if (qemudDomainSetSecurityLabel(h->conn, h->driver, h->vm) < 0) {
qemudReportError(h->conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- _("Failed to set security label"));
+ "%s", _("Failed to set security label"));
return -1;
}
@@ -3592,7 +3592,7 @@ static int qemudDomainGetSecurityLabel(virDomainPtr dom, virSecurityLabelPtr sec
if (driver->securityDriver && driver->securityDriver->domainGetSecurityLabel) {
if (driver->securityDriver->domainGetSecurityLabel(dom->conn, vm, seclabel) == -1) {
qemudReportError(dom->conn, dom, NULL, VIR_ERR_INTERNAL_ERROR,
- _("Failed to get security label"));
+ "%s", _("Failed to get security label"));
goto cleanup;
}
}
diff --git a/src/storage_backend.c b/src/storage_backend.c
index 67815d7..9f2dcca 100644
--- a/src/storage_backend.c
+++ b/src/storage_backend.c
@@ -423,7 +423,7 @@ virStorageBackendCreateQemuImg(virConnectPtr conn,
use_kvmimg = 0;
else {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("unable to find kvm-img or qemu-img"));
+ "%s", _("unable to find kvm-img or qemu-img"));
return -1;
}
@@ -485,9 +485,9 @@ virStorageBackendCreateQcowCreate(virConnectPtr conn,
return -1;
}
if (vol->backingStore.path != NULL) {
- virStorageReportError(conn, VIR_ERR_NO_SUPPORT,
+ virStorageReportError(conn, VIR_ERR_NO_SUPPORT, "%s",
_("copy-on-write image not supported with "
- "qcow-create"));
+ "qcow-create"));
return -1;
}
diff --git a/src/virsh.c b/src/virsh.c
index fff73a1..4499aca 100644
--- a/src/virsh.c
+++ b/src/virsh.c
@@ -4869,7 +4869,7 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd)
origpool = virStoragePoolLookupByVolume(origvol);
if (!origpool) {
- vshError(ctl, FALSE, _("failed to get parent pool"));
+ vshError(ctl, FALSE, "%s", _("failed to get parent pool"));
goto cleanup;
}
@@ -6583,7 +6583,7 @@ cmdCd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
int found;
if (!ctl->imode) {
- vshError(ctl, FALSE, _("cd: command valid only in interactive mode"));
+ vshError(ctl, FALSE, "%s", _("cd: command valid only in interactive mode"));
return -1;
}
--
1.6.0.6
15 years, 4 months
[libvirt] [PATCH 0/8] Support cgroups in QEMU driver (v2)
by Daniel P. Berrange
This is an updated series of the v1 patches here:
http://www.redhat.com/archives/libvir-list/2009-July/msg00435.html
I have re-ordered the patches a little to put the generic refactoring
all first. I identified some bugs in the existing LXC driver schedular
parameter handling which I fixed. Also fixed virsh to use the correct
data types when setting schedular parameters instead of hardcoding
a bogus type. Finally, I've made QEMU's use of cgroups configurable.
Daniel P. Berrange (8):
Use enums for cgroup controller types / labels
Use virFileReadAll/virFileWriteStr for key cgroup read/write helpers
Make cgroups a little more efficient
Refactor cgroups to allow a group per driver to be managed directly
Place every QEMU guest in a private cgroup
Implement schedular tunables API using cgroups
Use cgroups for block device whitelisting in QEMU guests
Make QEMU cgroups use configurable
qemud/libvirtd_qemu.aug | 2 +
qemud/test_libvirtd_qemu.aug | 21 +-
src/Makefile.am | 3 +-
src/cgroup.c | 867 +++++++++++++++++++++++-------------------
src/cgroup.h | 42 ++-
src/libvirt_private.syms | 2 +
src/lxc_conf.h | 2 +
src/lxc_controller.c | 19 +-
src/lxc_driver.c | 34 ++-
src/qemu.conf | 34 ++
src/qemu_conf.c | 61 +++
src/qemu_conf.h | 5 +
src/qemu_driver.c | 399 +++++++++++++++++++-
src/util.c | 47 +++-
src/util.h | 5 +
src/virsh.c | 232 +++++++-----
16 files changed, 1237 insertions(+), 538 deletions(-)
15 years, 4 months
[libvirt] clone memory leak and libvirt connection selection
by Johnny Luong
Hi,
I'm trying to use libvirt-0.6.5 within a multithreaded application without
libvirtd and from what it looks like, it appears to have two things
that are somewhat undesirable:
1) It tries to connect to libvirtd which isn't running. But it does
eventually connect to the hypervisor.
2) It appears to leak some memory within a readonly
connect and close. This is not too bad but it would be an issue in my
long lived daemon application.
I've attached an example program illustrating the issue with the linker log
and the log from valgrind showing the memory leak. The code itself
is based off the one on the website. Is there a URI I can use to avoid
the connection to the libvirtd daemon while still connecting to the
xendstore
and is the memory leak an issue with the application environment or the
library?
Let me know if you need any more information.
Thanks,
Johnny
15 years, 4 months
[libvirt] [PATCH 0/2] Add some more features to LXC driver
by Daniel P. Berrange
This patch series simply adds a couple of easy features to
the LXC driver.
Daniel P. Berrange (2):
Add domain events support to LXC driver
Add domain autostart for LXC driver
src/lxc_conf.h | 7 +
src/lxc_driver.c | 365 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 367 insertions(+), 5 deletions(-)
15 years, 4 months
[libvirt] MemoryPeek() is slow
by Jun Koi
Hi,
I play around with MemoryPeek() API on QEMU. While it works well, I
found that it is too slow.
That is expected because of the way it works: we always need to save
memory to a file, and read it in again, and that is too inefficient.
I am trying to figure out a better way to do this. To do that, clearly
we need to re-architecture QEMU for this: We must have another way to
read memory from outside the QEMU process.
Anybody could suggest a solution for this problem? I am willing to
spend time on this feature to improve the situation.
Thanks,
J
15 years, 4 months
[libvirt] PATCH: Fix many many win32 bugs
by Daniel P. Berrange
Latest GCC changed the meaning of 'printf' attribute annotation to refer
to the host platform's native format specifiers. On Win32/mingw32 this
means it is now validating against Microsoft's useless format specifiers.
We replace all the printf like functions on Win32 thanks to GNULIB and
thus should always validate against the GNU format specifiers.
This means we have to use the 'gnu_printf' annotation everywhere, but
only for GCC >= 4.4.
This also disables the 'pwd' and 'cd' commands in virsh because neither
of those build successfully on Win32.
Finally, disables the OpenNebula driver on Win32
Daniel
diff --git a/HACKING b/HACKING
index ca39d61..da28e98 100644
--- a/HACKING
+++ b/HACKING
@@ -312,7 +312,7 @@ gcc's printf attribute directive in the prototype. For example, here's
the one for virAsprintf, in util.h:
int virAsprintf(char **strp, const char *fmt, ...)
- ATTRIBUTE_FORMAT(printf, 2, 3);
+ ATTRIBUTE_FMT_PRINTF(2, 3);
This makes it so gcc's -Wformat and -Wformat-security options can do
their jobs and cross-check format strings with the number and types
diff --git a/autobuild.sh b/autobuild.sh
index 54abede..d090e74 100755
--- a/autobuild.sh
+++ b/autobuild.sh
@@ -76,6 +76,7 @@ if [ -x /usr/bin/i686-pc-mingw32-gcc ]; then
--without-uml \
--without-vbox \
--without-openvz \
+ --without-one \
--without-libvirtd
make
diff --git a/mingw32-libvirt.spec.in b/mingw32-libvirt.spec.in
index 271c6ca..9514032 100644
--- a/mingw32-libvirt.spec.in
+++ b/mingw32-libvirt.spec.in
@@ -52,6 +52,7 @@ MinGW Windows libvirt virtualization library.
--without-uml \
--without-vbox \
--without-openvz \
+ --without-one \
--without-libvirtd
make
@@ -90,6 +91,7 @@ rm -rf $RPM_BUILD_ROOT
%{_mingw32_datadir}/libvirt/schemas/storagevol.rng
%{_mingw32_datadir}/libvirt/schemas/nodedev.rng
%{_mingw32_datadir}/libvirt/schemas/capability.rng
+%{_mingw32_datadir}/libvirt/schemas/interface.rng
%{_mingw32_datadir}/locale/*/LC_MESSAGES/libvirt.mo
diff --git a/qemud/dispatch.h b/qemud/dispatch.h
index ab45b19..1d85df9 100644
--- a/qemud/dispatch.h
+++ b/qemud/dispatch.h
@@ -41,7 +41,7 @@ remoteDispatchClientRequest (struct qemud_server *server,
void remoteDispatchFormatError (remote_error *rerr,
const char *fmt, ...)
- ATTRIBUTE_FORMAT(printf, 2, 3);
+ ATTRIBUTE_FMT_PRINTF(2, 3);
void remoteDispatchAuthError (remote_error *rerr);
void remoteDispatchGenericError (remote_error *rerr);
diff --git a/qemud/qemud.h b/qemud/qemud.h
index abacbbb..254db44 100644
--- a/qemud/qemud.h
+++ b/qemud/qemud.h
@@ -52,15 +52,61 @@
#ifdef HAVE_ANSIDECL_H
#include <ansidecl.h>
#endif
+
+#ifndef __GNUC_PREREQ
+#if defined __GNUC__ && defined __GNUC_MINOR__
+# define __GNUC_PREREQ(maj, min) \
+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+#else
+#define __GNUC_PREREQ(maj,min) 0
+#endif
+#endif
+
+/**
+ * ATTRIBUTE_UNUSED:
+ *
+ * Macro to flag conciously unused parameters to functions
+ */
#ifndef ATTRIBUTE_UNUSED
#define ATTRIBUTE_UNUSED __attribute__((__unused__))
#endif
-#ifndef ATTRIBUTE_FORMAT
-#define ATTRIBUTE_FORMAT(args...) __attribute__((__format__ (args)))
+
+/**
+ * ATTRIBUTE_FMT_PRINTF
+ *
+ * Macro used to check printf like functions, if compiling
+ * with gcc.
+ *
+ * We use gnulib which guarentees we always have GNU style
+ * printf format specifiers even on broken Win32 platforms
+ * hence we have to force 'gnu_printf' for new GCC
+ */
+#ifndef ATTRIBUTE_FMT_PRINTF
+#if __GNUC_PREREQ (4, 4)
+#define ATTRIBUTE_FMT_PRINTF(fmtpos,argpos) __attribute__((__format__ (gnu_printf, fmtpos,argpos)))
+#else
+#define ATTRIBUTE_FMT_PRINTF(fmtpos,argpos) __attribute__((__format__ (printf, fmtpos,argpos)))
+#endif
#endif
+
+#ifndef ATTRIBUTE_RETURN_CHECK
+#if __GNUC_PREREQ (3, 4)
+#define ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__))
#else
+#define ATTRIBUTE_RETURN_CHECK
+#endif
+#endif
+
+#else
+#ifndef ATTRIBUTE_UNUSED
#define ATTRIBUTE_UNUSED
-#define ATTRIBUTE_FORMAT(...)
+#endif
+#ifndef ATTRIBUTE_FMT_PRINTF
+#define ATTRIBUTE_FMT_PRINTF(...)
+#endif
+#ifndef ATTRIBUTE_RETURN_CHECK
+#define ATTRIBUTE_RETURN_CHECK
+#endif
#endif
#define qemudDebug DEBUG
@@ -213,7 +259,7 @@ struct qemud_server {
};
void qemudLog(int priority, const char *fmt, ...)
- ATTRIBUTE_FORMAT(printf,2,3);
+ ATTRIBUTE_FMT_PRINTF(2,3);
diff --git a/src/buf.h b/src/buf.h
index 0b78d17..7d31cb2 100644
--- a/src/buf.h
+++ b/src/buf.h
@@ -40,7 +40,7 @@ unsigned int virBufferUse(const virBufferPtr buf);
void virBufferAdd(const virBufferPtr buf, const char *str, int len);
void virBufferAddChar(const virBufferPtr buf, char c);
void virBufferVSprintf(const virBufferPtr buf, const char *format, ...)
- ATTRIBUTE_FORMAT(printf, 2, 3);
+ ATTRIBUTE_FMT_PRINTF(2, 3);
void virBufferStrcat(const virBufferPtr buf, ...);
void virBufferEscapeString(const virBufferPtr buf, const char *format, const char *str);
void virBufferURIEncodeString (const virBufferPtr buf, const char *str);
diff --git a/src/internal.h b/src/internal.h
index adb6507..cf7e196 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -67,8 +67,13 @@
#ifdef __GNUC__
#ifndef __GNUC_PREREQ
+#if defined __GNUC__ && defined __GNUC_MINOR__
+# define __GNUC_PREREQ(maj, min) \
+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+#else
#define __GNUC_PREREQ(maj,min) 0
#endif
+#endif
/**
* ATTRIBUTE_UNUSED:
@@ -80,13 +85,21 @@
#endif
/**
- * ATTRIBUTE_FORMAT
+ * ATTRIBUTE_FMT_PRINTF
*
- * Macro used to check printf/scanf-like functions, if compiling
+ * Macro used to check printf like functions, if compiling
* with gcc.
+ *
+ * We use gnulib which guarentees we always have GNU style
+ * printf format specifiers even on broken Win32 platforms
+ * hence we have to force 'gnu_printf' for new GCC
*/
-#ifndef ATTRIBUTE_FORMAT
-#define ATTRIBUTE_FORMAT(args...) __attribute__((__format__ (args)))
+#ifndef ATTRIBUTE_FMT_PRINTF
+#if __GNUC_PREREQ (4, 4)
+#define ATTRIBUTE_FMT_PRINTF(fmtpos,argpos) __attribute__((__format__ (gnu_printf, fmtpos,argpos)))
+#else
+#define ATTRIBUTE_FMT_PRINTF(fmtpos,argpos) __attribute__((__format__ (printf, fmtpos,argpos)))
+#endif
#endif
#ifndef ATTRIBUTE_RETURN_CHECK
@@ -98,9 +111,15 @@
#endif
#else
+#ifndef ATTRIBUTE_UNUSED
#define ATTRIBUTE_UNUSED
-#define ATTRIBUTE_FORMAT(...)
+#endif
+#ifndef ATTRIBUTE_FMT_PRINTF
+#define ATTRIBUTE_FMT_PRINTF(...)
+#endif
+#ifndef ATTRIBUTE_RETURN_CHECK
#define ATTRIBUTE_RETURN_CHECK
+#endif
#endif /* __GNUC__ */
/*
diff --git a/src/logging.h b/src/logging.h
index 0b9ae79..f1e2525 100644
--- a/src/logging.h
+++ b/src/logging.h
@@ -121,6 +121,6 @@ extern int virLogParseFilters(const char *filters);
extern int virLogParseOutputs(const char *output);
extern void virLogMessage(const char *category, int priority,
const char *funcname, long long linenr, int flags,
- const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 6, 7);
+ const char *fmt, ...) ATTRIBUTE_FMT_PRINTF(6, 7);
#endif
diff --git a/src/security.h b/src/security.h
index 585caa0..5fc3086 100644
--- a/src/security.h
+++ b/src/security.h
@@ -82,7 +82,7 @@ virSecurityDriverVerify(virConnectPtr conn, virDomainDefPtr def);
void
virSecurityReportError(virConnectPtr conn, int code, const char *fmt, ...)
- ATTRIBUTE_FORMAT(printf, 3, 4);
+ ATTRIBUTE_FMT_PRINTF(3, 4);
/* Helpers */
void virSecurityDriverInit(virSecurityDriverPtr drv);
diff --git a/src/sexpr.h b/src/sexpr.h
index c3d038e..1d9adaa 100644
--- a/src/sexpr.h
+++ b/src/sexpr.h
@@ -49,7 +49,7 @@ void sexpr_free(struct sexpr *sexpr);
const char *sexpr_node(const struct sexpr *sexpr, const char *node);
int sexpr_node_copy(const struct sexpr *sexpr, const char *node, char **dst);
const char *sexpr_fmt_node(const struct sexpr *sexpr, const char *fmt, ...)
- ATTRIBUTE_FORMAT(printf,2,3);
+ ATTRIBUTE_FMT_PRINTF(2,3);
struct sexpr *sexpr_lookup(const struct sexpr *sexpr, const char *node);
int sexpr_has(const struct sexpr *sexpr, const char *node);
#endif
diff --git a/src/threads-win32.c b/src/threads-win32.c
index 10233b0..ef3f2ef 100644
--- a/src/threads-win32.c
+++ b/src/threads-win32.c
@@ -41,8 +41,10 @@ void virCondEventCleanup(void *data);
int virThreadInitialize(void)
{
- virMutexInit(&virThreadLocalLock);
- virThreadLocalInit(&virCondEvent, virCondEventCleanup);
+ if (virMutexInit(&virThreadLocalLock) < 0)
+ return -1;
+ if (virThreadLocalInit(&virCondEvent, virCondEventCleanup) < 0)
+ return -1;
return 0;
}
diff --git a/src/util.h b/src/util.h
index 1a7286c..43a5bbc 100644
--- a/src/util.h
+++ b/src/util.h
@@ -160,7 +160,7 @@ int virMacAddrCompare (const char *mac1, const char *mac2);
void virSkipSpaces(const char **str);
int virParseNumber(const char **str);
int virAsprintf(char **strp, const char *fmt, ...)
- ATTRIBUTE_FORMAT(printf, 2, 3);
+ ATTRIBUTE_FMT_PRINTF(2, 3);
#define VIR_MAC_BUFLEN 6
#define VIR_MAC_PREFIX_BUFLEN 3
diff --git a/src/virsh.c b/src/virsh.c
index fff73a1..6919292 100644
--- a/src/virsh.c
+++ b/src/virsh.c
@@ -202,7 +202,7 @@ typedef struct __vshControl {
static const vshCmdDef commands[];
static void vshError(vshControl *ctl, int doexit, const char *format, ...)
- ATTRIBUTE_FORMAT(printf, 3, 4);
+ ATTRIBUTE_FMT_PRINTF(3, 4);
static int vshInit(vshControl *ctl);
static int vshDeinit(vshControl *ctl);
static void vshUsage(void);
@@ -272,9 +272,9 @@ static virStorageVolPtr vshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd,
VSH_BYUUID|VSH_BYNAME)
static void vshPrintExtra(vshControl *ctl, const char *format, ...)
- ATTRIBUTE_FORMAT(printf, 2, 3);
+ ATTRIBUTE_FMT_PRINTF(2, 3);
static void vshDebug(vshControl *ctl, int level, const char *format, ...)
- ATTRIBUTE_FORMAT(printf, 3, 4);
+ ATTRIBUTE_FMT_PRINTF(3, 4);
/* XXX: add batch support */
#define vshPrint(_ctl, ...) fprintf(stdout, __VA_ARGS__)
@@ -495,6 +495,8 @@ cmdConnect(vshControl *ctl, const vshCmd *cmd)
return ctl->conn ? TRUE : FALSE;
}
+#ifndef WIN32
+
/*
* "console" command
*/
@@ -510,8 +512,6 @@ static const vshCmdOptDef opts_console[] = {
{NULL, 0, 0, NULL}
};
-#ifndef __MINGW32__
-
static int
cmdRunConsole(vshControl *ctl, virDomainPtr dom)
{
@@ -574,17 +574,6 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom)
return ret;
}
-#else /* __MINGW32__ */
-
-static int
-cmdRunConsole(vshControl *ctl, virDomainPtr dom ATTRIBUTE_UNUSED)
-{
- vshError (ctl, FALSE, "%s", _("console not implemented on this platform"));
- return FALSE;
-}
-
-#endif /* __MINGW32__ */
-
static int
cmdConsole(vshControl *ctl, const vshCmd *cmd)
{
@@ -603,6 +592,9 @@ cmdConsole(vshControl *ctl, const vshCmd *cmd)
return ret;
}
+#endif /* WIN32 */
+
+
/*
* "list" command
*/
@@ -931,7 +923,9 @@ static const vshCmdInfo info_create[] = {
static const vshCmdOptDef opts_create[] = {
{"file", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("file containing an XML domain description")},
+#ifndef WIN32
{"console", VSH_OT_BOOL, 0, gettext_noop("attach to console after creation")},
+#endif
{NULL, 0, 0, NULL}
};
@@ -943,7 +937,9 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd)
int found;
int ret = TRUE;
char *buffer;
+#ifndef WIN32
int console = vshCommandOptBool(cmd, "console");
+#endif
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
return FALSE;
@@ -961,8 +957,10 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd)
if (dom != NULL) {
vshPrint(ctl, _("Domain %s created from %s\n"),
virDomainGetName(dom), from);
+#ifndef WIN32
if (console)
cmdRunConsole(ctl, dom);
+#endif
virDomainFree(dom);
} else {
vshError(ctl, FALSE, _("Failed to create domain from %s"), from);
@@ -1083,7 +1081,9 @@ static const vshCmdInfo info_start[] = {
static const vshCmdOptDef opts_start[] = {
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("name of the inactive domain")},
+#ifndef WIN32
{"console", VSH_OT_BOOL, 0, gettext_noop("attach to console after creation")},
+#endif
{NULL, 0, 0, NULL}
};
@@ -1092,7 +1092,9 @@ cmdStart(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
int ret = TRUE;
+#ifndef WIN32
int console = vshCommandOptBool(cmd, "console");
+#endif
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
return FALSE;
@@ -1109,8 +1111,10 @@ cmdStart(vshControl *ctl, const vshCmd *cmd)
if (virDomainCreate(dom) == 0) {
vshPrint(ctl, _("Domain %s started\n"),
virDomainGetName(dom));
+#ifndef WIN32
if (console)
cmdRunConsole(ctl, dom);
+#endif
} else {
vshError(ctl, FALSE, _("Failed to start domain %s"),
virDomainGetName(dom));
@@ -6562,6 +6566,8 @@ editReadBackFile (vshControl *ctl, const char *filename)
return ret;
}
+
+#ifndef WIN32
/*
* "cd" command
*/
@@ -6603,6 +6609,9 @@ cmdCd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
return 0;
}
+#endif
+
+#ifndef WIN32
/*
* "pwd" command
*/
@@ -6638,6 +6647,7 @@ cmdPwd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
free (cwd);
return !err;
}
+#endif
/*
* "edit" command
@@ -6802,9 +6812,13 @@ static const vshCmdDef commands[] = {
{"attach-interface", cmdAttachInterface, opts_attach_interface, info_attach_interface},
{"autostart", cmdAutostart, opts_autostart, info_autostart},
{"capabilities", cmdCapabilities, NULL, info_capabilities},
+#ifndef WIN32
{"cd", cmdCd, opts_cd, info_cd},
+#endif
{"connect", cmdConnect, opts_connect, info_connect},
+#ifndef WIN32
{"console", cmdConsole, opts_console, info_console},
+#endif
{"create", cmdCreate, opts_create, info_create},
{"start", cmdStart, opts_start, info_start},
{"destroy", cmdDestroy, opts_destroy, info_destroy},
@@ -6882,7 +6896,9 @@ static const vshCmdDef commands[] = {
{"pool-undefine", cmdPoolUndefine, opts_pool_undefine, info_pool_undefine},
{"pool-uuid", cmdPoolUuid, opts_pool_uuid, info_pool_uuid},
+#ifndef WIN32
{"pwd", cmdPwd, NULL, info_pwd},
+#endif
{"quit", cmdQuit, NULL, info_quit},
{"reboot", cmdReboot, opts_reboot, info_reboot},
{"restore", cmdRestore, opts_restore, info_restore},
diff --git a/src/virterror_internal.h b/src/virterror_internal.h
index fe9a96f..da89de7 100644
--- a/src/virterror_internal.h
+++ b/src/virterror_internal.h
@@ -46,7 +46,7 @@ void virRaiseErrorFull(virConnectPtr conn,
int int1,
int int2,
const char *fmt, ...)
- ATTRIBUTE_FORMAT(printf, 13, 14);
+ ATTRIBUTE_FMT_PRINTF(13, 14);
/* Includes 'dom' and 'net' for compatbility, but they're ignored */
#define virRaiseError(conn, dom, net, domain, code, level, \
@@ -61,7 +61,7 @@ void virReportErrorHelper(virConnectPtr conn, int domcode, int errcode,
const char *funcname ATTRIBUTE_UNUSED,
size_t linenr ATTRIBUTE_UNUSED,
const char *fmt, ...)
- ATTRIBUTE_FORMAT(printf, 7, 8);
+ ATTRIBUTE_FMT_PRINTF(7, 8);
void virReportSystemErrorFull(virConnectPtr conn,
int domcode,
@@ -70,7 +70,7 @@ void virReportSystemErrorFull(virConnectPtr conn,
const char *funcname,
size_t linenr,
const char *fmt, ...)
- ATTRIBUTE_FORMAT(printf, 7, 8);
+ ATTRIBUTE_FMT_PRINTF(7, 8);
#define virReportSystemError(conn, theerrno, fmt,...) \
virReportSystemErrorFull((conn), \
diff --git a/src/xend_internal.c b/src/xend_internal.c
index 55ffd3f..e23ae2b 100644
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -582,7 +582,7 @@ xend_op(virConnectPtr xend, const char *name, const char *key, ...)
* Returns a parsed S-Expression in case of success, NULL in case of failure
*/
static struct sexpr *sexpr_get(virConnectPtr xend, const char *fmt, ...)
- ATTRIBUTE_FORMAT(printf,2,3);
+ ATTRIBUTE_FMT_PRINTF(2,3);
static struct sexpr *
sexpr_get(virConnectPtr xend, const char *fmt, ...)
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
15 years, 4 months
[libvirt] How to config my VM to use KVM with libvirt?
by Jun Koi
Hi,
I have a VM running under libvirt, and it is currently run with
-no-kvm option (I saw that in "ps" output).
Now I want to run this VM with KVM. How can I reconfigure it for that?
I looked into its configuration file under /etc/libvirt/qemu, but
didnt see any option to turn KVM on.
Thanks,
J
15 years, 4 months