[libvirt] [PATCH] udev_device_get_devpath might return NULL
by Guido Günther
Fix crash on daemon strdup in that case.
udev_device_get_devpath returs NULL for
'/sys/devices/virtual/block/dm-*' devices. In that case the later strdup
segfaults. O.k. to apply?
19:12:46.319: info : udevGetDeviceProperty:111 : udev reports device 'dm-0' does not have property 'DRIVER'
19:12:46.319: debug : udevProcessStorage:954 : No devnode for '/devices/virtual/block/dm-0'
19:12:46.319: info : udevProcessDeviceListEntry:1261 : Failed to create node device for udev device '/sys/devices/virtual/block/dm-0'
---
src/node_device/node_device_udev.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 9b48052..c7238fc 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -947,8 +947,14 @@ static int udevProcessStorage(struct udev_device *device,
{
union _virNodeDevCapData *data = &def->caps->data;
int ret = -1;
+ const char* devnode;
- data->storage.block = strdup(udev_device_get_devnode(device));
+ devnode = udev_device_get_devnode(device);
+ if(!devnode) {
+ VIR_DEBUG("No devnode for '%s'\n", udev_device_get_devpath(device));
+ goto out;
+ }
+ data->storage.block = strdup(devnode);
if (udevGetStringProperty(device,
"DEVNAME",
&data->storage.block) == PROPERTY_ERROR) {
--
1.6.5.3
15 years
[libvirt] [PATCH] Avoid an type-punned pointer aliasing pbm
by Daniel Veillard
Anmother fix for a warning which I didn't commited yet:
commit 3109546b28b5fc55bf451e62cdb80908cf025ff8
Author: Daniel Veillard <veillard(a)redhat.com>
Date: Tue Dec 8 11:14:55 2009 +0100
Avoid an type-punned pointer aliasing pbm
Fix this warning, there is no need to use an intermediate,
different array pointer.
network.c: In function 'getIPv6Addr':
network.c:50: warning: dereferencing type-punned pointer will break strict-aliasing rules
* src/util/network.c: avoid an intermediary pointer cast
diff --git a/src/util/network.c b/src/util/network.c
index aaea436..9b9b848 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -41,16 +41,13 @@ static int getIPv4Addr(virSocketAddrPtr addr, virIPv4AddrPtr tab) {
}
static int getIPv6Addr(virSocketAddrPtr addr, virIPv6AddrPtr tab) {
- virIPv6AddrPtr val;
int i;
if ((addr == NULL) || (tab == NULL) || (addr->stor.ss_family != AF_INET6))
return(-1);
- val = (virIPv6AddrPtr) &(addr->inet6.sin6_addr.s6_addr16);
-
for (i = 0;i < 8;i++) {
- (*tab)[i] = ntohs((*val)[i]);
+ (*tab)[i] = ntohs(addr->inet6.sin6_addr.s6_addr16[i]);
}
return(0);
--
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/
15 years
[libvirt] [PATCH] Fix compilation for configure --disable-nls
by Matthias Bolte
---
src/opennebula/one_conf.c | 2 +-
src/opennebula/one_driver.c | 16 ++++++++--------
src/phyp/phyp_driver.c | 22 +++++++++++-----------
src/xen/xen_driver.c | 6 +++---
4 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/src/opennebula/one_conf.c b/src/opennebula/one_conf.c
index 415f832..baef217 100644
--- a/src/opennebula/one_conf.c
+++ b/src/opennebula/one_conf.c
@@ -147,7 +147,7 @@ int oneSubmitVM(virConnectPtr conn,
if ((oneid = c_oneAllocateTemplate(templ)) < 0) {
oneError(conn, NULL, VIR_ERR_OPERATION_FAILED,
- _("Error submitting virtual machine to OpenNebula"));
+ "%s", _("Error submitting virtual machine to OpenNebula"));
VIR_FREE(templ);
return -1;
}
diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c
index 4857f54..a30c110 100644
--- a/src/opennebula/one_driver.c
+++ b/src/opennebula/one_driver.c
@@ -280,13 +280,13 @@ static int oneDomainUndefine(virDomainPtr dom)
vm =virDomainFindByUUID(&driver->domains, dom->uuid);
if (!vm) {
oneError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN,
- _("no domain with matching uuid"));
+ "%s", _("no domain with matching uuid"));
goto return_point;
}
if (!vm->persistent) {
oneError(dom->conn, dom, VIR_ERR_INTERNAL_ERROR,
- _("cannot undefine transient domain"));
+ "%s", _("cannot undefine transient domain"));
goto return_point;
}
virDomainRemoveInactive(&driver->domains, vm);
@@ -499,7 +499,7 @@ static int oneDomainShutdown(virDomainPtr dom)
if (c_oneShutdown(vm->pid)) {
oneError(dom->conn, dom, VIR_ERR_OPERATION_INVALID,
- _("Wrong state to perform action"));
+ "%s", _("Wrong state to perform action"));
goto return_point;
}
vm->state=VIR_DOMAIN_SHUTDOWN;
@@ -535,7 +535,7 @@ static int oneDomainDestroy(virDomainPtr dom)
/* VM not running, delete the instance at ONE DB */
if(c_oneFinalize(vm->pid)){
oneError(dom->conn, dom, VIR_ERR_OPERATION_INVALID,
- _("Wrong state to perform action"));
+ "%s", _("Wrong state to perform action"));
goto return_point;
}
}
@@ -570,11 +570,11 @@ static int oneDomainSuspend(virDomainPtr dom)
goto return_point;
}
oneError(dom->conn, dom, VIR_ERR_OPERATION_INVALID,
- _("Wrong state to perform action"));
+ "%s", _("Wrong state to perform action"));
goto return_point;
}
oneError(dom->conn,dom, VIR_ERR_OPERATION_INVALID,
- _("domain is not running"));
+ "%s", _("domain is not running"));
} else {
oneError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN,
_("no domain with matching id %d"), dom->id);
@@ -603,11 +603,11 @@ static int oneDomainResume(virDomainPtr dom)
goto return_point;
}
oneError(dom->conn, dom, VIR_ERR_OPERATION_INVALID,
- _("Wrong state to perform action"));
+ "%s", _("Wrong state to perform action"));
goto return_point;
}
oneError(dom->conn,dom, VIR_ERR_OPERATION_INVALID,
- _("domain is not paused "));
+ "%s", _("domain is not paused"));
} else {
oneError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN,
_("no domain with matching id %d"), dom->id);
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index ea9555a..dfbc968 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -91,19 +91,19 @@ phypOpen(virConnectPtr conn,
if (conn->uri->server == NULL) {
PHYP_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
- _("Missing server name in phyp:// URI"));
+ "%s", _("Missing server name in phyp:// URI"));
return VIR_DRV_OPEN_ERROR;
}
if (conn->uri->path == NULL) {
PHYP_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
- _("Missing managed system name in phyp:// URI"));
+ "%s", _("Missing managed system name in phyp:// URI"));
return VIR_DRV_OPEN_ERROR;
}
if (conn->uri->user == NULL) {
PHYP_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
- _("Missing username in phyp:// URI"));
+ "%s", _("Missing username in phyp:// URI"));
return VIR_DRV_OPEN_ERROR;
}
@@ -150,13 +150,13 @@ phypOpen(virConnectPtr conn,
if (escape_specialcharacters(conn->uri->path, string, len) == -1) {
PHYP_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
- _("Error parsing 'path'. Invalid characters."));
+ "%s", _("Error parsing 'path'. Invalid characters."));
goto failure;
}
if ((session = openSSHSession(conn, auth, &internal_socket)) == NULL) {
PHYP_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
- _("Error while opening SSH session."));
+ "%s", _("Error while opening SSH session."));
goto failure;
}
//conn->uri->path = string;
@@ -314,7 +314,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
LIBSSH2_ERROR_EAGAIN) ;
if (rc) {
PHYP_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
- _("Failure establishing SSH session."));
+ "%s", _("Failure establishing SSH session."));
goto disconnect;
}
@@ -344,7 +344,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
if (!auth || !auth->cb) {
PHYP_ERROR(conn, VIR_ERR_AUTH_FAILED,
- _("No authentication callback provided."));
+ "%s", _("No authentication callback provided."));
goto disconnect;
}
@@ -355,7 +355,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
if (!hasPassphrase) {
PHYP_ERROR(conn, VIR_ERR_AUTH_FAILED,
- _("Required credentials are not supported."));
+ "%s", _("Required credentials are not supported."));
goto disconnect;
}
@@ -364,7 +364,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
if (res < 0) {
PHYP_ERROR(conn, VIR_ERR_AUTH_FAILED,
- _("Unable to fetch credentials."));
+ "%s", _("Unable to fetch credentials."));
goto disconnect;
}
@@ -372,7 +372,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
password = creds[0].result;
} else {
PHYP_ERROR(conn, VIR_ERR_AUTH_FAILED,
- _("Unable to get password certificates"));
+ "%s", _("Unable to get password certificates"));
goto disconnect;
}
@@ -383,7 +383,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
if (rc) {
PHYP_ERROR(conn, VIR_ERR_AUTH_FAILED,
- _("Authentication failed"));
+ "%s", _("Authentication failed"));
goto disconnect;
} else
goto exit;
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index 4bfcce4..ed94bed 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -1316,14 +1316,14 @@ xenUnifiedDomainMigrateFinish (virConnectPtr dconn,
domain_xml = xenDaemonDomainDumpXML (dom, 0, NULL);
if (! domain_xml) {
xenUnifiedError(dconn, VIR_ERR_MIGRATE_PERSIST_FAILED,
- _("failed to get XML representation of migrated domain"));
+ "%s", _("failed to get XML representation of migrated domain"));
goto failure;
}
dom_new = xenDaemonDomainDefineXML (dconn, domain_xml);
if (! dom_new) {
- xenUnifiedError (dconn, VIR_ERR_MIGRATE_PERSIST_FAILED,
- _("failed to define domain on destination host"));
+ xenUnifiedError(dconn, VIR_ERR_MIGRATE_PERSIST_FAILED,
+ "%s", _("failed to define domain on destination host"));
goto failure;
}
--
1.6.0.4
15 years
[libvirt] [BUG] connection to vbox 3.1 fails
by Florian Vichot
Hello all,
As confirmed on IRC by Matthias, when trying to open a connection of any
sort (vbox:///session or vbox:///system) to the vbox driver with a
VirtualBox 3.1 installed, the connection fails with:
"internal error nsIEventQueue object is null"
This is printed by line 726 in vbox_tmpl.c.
This is with the 3.1 support patch commited earlier today.
The driver with a VirtualBox version 3.0.8 or 3.0.12 works fine with
that patch.
Thanks,
Florian
15 years
[libvirt] Libvirt/LXC (lxcControllerMain:380 : EPOLLHUP from fd 7)
by Tony Risinger
hello,
i am trying to use libvirt with LXC, and having some issues...
everything seems ok when using lxc-* tools. host box is Arch Linux.
ultimately i'm getting this error in the domain log:
.....
05:45:31.353: debug : lxcControllerMain:380 : EPOLLHUP from fd 7
i was getting this last night in #virt:
.....
20:49:57.545: error : lxcFdForward:230 : read of fd 7 failed: Input/output error
libvir: Linux Container error : read of fd 7 failed: Input/output error
instead of the former, but i can seem to reproduce now. i might have
replaced 0.7.4 version with git version... i dont remember. right now
the build is direct from master, and i am getting EPOLLHUP. didnt see
anything interesting in virsh or libvirtd debug output, but i can
paste/bin the whole thing or whatever else if need be.
-----VERSIONS/SOURCES
(loadmodconfig make target + below)
kernel: Linux PHS-001 2.6.32-custom #1 SMP PREEMPT Sun Dec 6 05:29:37
CST 2009 i686 Intel(R) Xeon(TM) CPU 3.20GHz GenuineIntel GNU/Linux
CONFIG_DEVPTS_MULTIPLE_INSTANCES=y
CONFIG_GROUP_SCHED=y
CONFIG_FAIR_GROUP_SCHED=y
CONFIG_RT_GROUP_SCHED=y
CONFIG_CGROUP_SCHED=y
CONFIG_CGROUPS=y
CONFIG_CGROUP_NS=y
CONFIG_CGROUP_FREEZER=y
CONFIG_CGROUP_DEVICE=y
CONFIG_CPUSETS=y
CONFIG_PROC_PID_CPUSET=y
CONFIG_CGROUP_CPUACCT=y
CONFIG_RESOURCE_COUNTERS=y
CONFIG_CGROUP_MEM_RES_CTLR=y
CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y
CONFIG_MM_OWNER=y
CONFIG_NAMESPACES=y
CONFIG_UTS_NS=y
CONFIG_IPC_NS=y
CONFIG_USER_NS=y
CONFIG_PID_NS=y
CONFIG_NET_NS=y
CONFIG_NET_CLS_CGROUP=y
CONFIG_SECURITY_FILE_CAPABILITIES=y
(built from master)
libvirt: http://aur.archlinux.org/packages/libvirt-git/libvirt-git/PKGBUILD
--with-capng
--with-network
--with-lxc
--without-xen
--without-xen-inotify
--without-qemu
--without-uml
--without-openvz
--without-vbox
--without-one
--without-esx
libcap-ng: http://aur.archlinux.org/packages/libcap-ng/libcap-ng/PKGBUILD
container: http://www.stgraber.org/2009/11/06/lxc-containers-or-extremely-fast-virtu...
http://www.stgraber.org/download/lxc-ubuntu-8.04-i386.tar.gz
-----CONFIGURATION
# host ptmx symlinked to pts/ptmx
[root@PHS-001 vps]# ls -l /dev/ptmx
lrwxrwxrwx 1 root root 8 2009-12-08 04:40 /dev/ptmx -> pts/ptmx
# guest ptmx symlinked to pts/ptmx
[root@PHS-001 vps]# ls -l /vps/dom/ubuntu/root/dev/ptmx
lrwxrwxrwx 1 root root 8 2009-12-06 04:11
/vps/dom/ubuntu/root/dev/ptmx -> pts/ptmx
# host devpts mounted newinstance
[root@PHS-001 vps]# mount | grep devpts
none on /dev/pts type devpts (rw,newinstance)
# single cgroup mount on host
[root@PHS-001 vps]# mount | grep cgroup
none on /cgroup type cgroup (rw)
# libvirt config
[root@PHS-001 vps]# grep -v -e '^#\|^ *$' /etc/libvirt/libvirtd.conf
auth_unix_ro = "none"
auth_unix_rw = "none"
# guest config...
# i have tried the legacy <console type='pty' /> with same results
# i dont fully understand this, why do i need to specify a host/source pty?
[root@PHS-001 vps]# cat /vps/def/exec/sys/ubuntu.xml
<domain type='lxc'>
<name>ubuntu</name>
<memory>500000</memory>
<os>
<type arch='i686'>exe</type>
<init>/sbin/init</init>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<filesystem type='mount'>
<source dir='/vps/dom/ubuntu/root'/>
<target dir='/'/>
</filesystem>
<console type='pty'>
<source path='/dev/pts/4'/>
<target port='0'/>
</console>
</devices>
</domain>
-----PROCEDURE
[root@PHS-001 vps]# LIBVIRT_DEBUG=1 libvirtd --daemon
05:42:46.121: debug : virInitialize:278 : register drivers
.....
[root@PHS-001 vps]# virsh -c lxc:/// define /vps/def/exec/sys/ubuntu.xml
Domain ubuntu defined from /vps/def/exec/sys/ubuntu.xml
[root@PHS-001 vps]# virsh -c lxc:/// define /vps/def/exec/sys/ubuntu.xml
Domain ubuntu defined from /vps/def/exec/sys/ubuntu.xml
[root@PHS-001 vps]# virsh -c lxc:/// start ubuntu
Domain ubuntu started
[root@PHS-001 vps]# virsh -c lxc:/// console ubuntu
error: Unable to get domain status
error: internal error Unable to get cgroup for ubuntu
-----LOGS
# /var/log/libvirt/lxc/ubuntu.log
05:45:31.105: debug : lxcControllerRun:540 : Setting up private /dev/pts
05:45:31.125: debug : lxcControllerRun:566 : Mouting 'devpts' on
/vps/dom/ubuntu/root/dev/pts
05:45:31.125: debug : lxcControllerRun:581 : Opening tty on private
/vps/dom/ubuntu/root/dev/pts/ptmx
05:45:31.125: debug : virCgroupNew:492 : New group /
05:45:31.125: debug : virCgroupDetect:230 : Detected mount/mapping
0:cpu at /cgroup in /1534
05:45:31.125: debug : virCgroupDetect:230 : Detected mount/mapping
1:cpuacct at /cgroup in /1534
05:45:31.125: debug : virCgroupDetect:230 : Detected mount/mapping
2:cpuset at /cgroup in /1534
05:45:31.125: debug : virCgroupDetect:230 : Detected mount/mapping
3:memory at /cgroup in /1534
05:45:31.125: debug : virCgroupDetect:230 : Detected mount/mapping
4:devices at /cgroup in /1534
05:45:31.125: debug : virCgroupDetect:230 : Detected mount/mapping
5:freezer at /cgroup in /1534
05:45:31.125: debug : virCgroupNew:492 : New group /libvirt
05:45:31.125: debug : virCgroupDetect:230 : Detected mount/mapping
0:cpu at /cgroup in /1534
05:45:31.125: debug : virCgroupDetect:230 : Detected mount/mapping
1:cpuacct at /cgroup in /1534
05:45:31.125: debug : virCgroupDetect:230 : Detected mount/mapping
2:cpuset at /cgroup in /1534
05:45:31.125: debug : virCgroupDetect:230 : Detected mount/mapping
3:memory at /cgroup in /1534
05:45:31.125: debug : virCgroupDetect:230 : Detected mount/mapping
4:devices at /cgroup in /1534
05:45:31.125: debug : virCgroupDetect:230 : Detected mount/mapping
5:freezer at /cgroup in /1534
05:45:31.125: debug : virCgroupMakeGroup:450 : Make group /libvirt
05:45:31.125: debug : virCgroupMakeGroup:462 : Make controller
/cgroup/1534/libvirt/
05:45:31.125: debug : virCgroupCpuSetInherit:416 : Setting up
inheritance / -> /libvirt
05:45:31.126: debug : virCgroupGetValueStr:305 : Get value
/cgroup/1534/cpuset.cpus
05:45:31.126: debug : virCgroupCpuSetInherit:429 : Inherit cpuset.cpus = 0-3
05:45:31.126: debug : virCgroupSetValueStr:275 : Set value
/cgroup/1534/libvirt/cpuset.cpus
05:45:31.126: debug : virCgroupGetValueStr:305 : Get value
/cgroup/1534/cpuset.mems
05:45:31.126: debug : virCgroupCpuSetInherit:429 : Inherit cpuset.mems = 0
05:45:31.126: debug : virCgroupSetValueStr:275 : Set value
/cgroup/1534/libvirt/cpuset.mems
05:45:31.126: debug : virCgroupMakeGroup:462 : Make controller
/cgroup/1534/libvirt/
05:45:31.126: debug : virCgroupMakeGroup:462 : Make controller
/cgroup/1534/libvirt/
05:45:31.126: debug : virCgroupMakeGroup:462 : Make controller
/cgroup/1534/libvirt/
05:45:31.126: debug : virCgroupMakeGroup:462 : Make controller
/cgroup/1534/libvirt/
05:45:31.126: debug : virCgroupMakeGroup:462 : Make controller
/cgroup/1534/libvirt/
05:45:31.126: debug : virCgroupNew:492 : New group /libvirt/lxc
05:45:31.126: debug : virCgroupDetect:230 : Detected mount/mapping
0:cpu at /cgroup in /1534
05:45:31.126: debug : virCgroupDetect:230 : Detected mount/mapping
1:cpuacct at /cgroup in /1534
05:45:31.126: debug : virCgroupDetect:230 : Detected mount/mapping
2:cpuset at /cgroup in /1534
05:45:31.126: debug : virCgroupDetect:230 : Detected mount/mapping
3:memory at /cgroup in /1534
05:45:31.126: debug : virCgroupDetect:230 : Detected mount/mapping
4:devices at /cgroup in /1534
05:45:31.126: debug : virCgroupDetect:230 : Detected mount/mapping
5:freezer at /cgroup in /1534
05:45:31.126: debug : virCgroupMakeGroup:450 : Make group /libvirt/lxc
05:45:31.126: debug : virCgroupMakeGroup:462 : Make controller
/cgroup/1534/libvirt/lxc/
05:45:31.211: debug : lxcContainerStart:832 : clone() returned, 1536
05:45:31.353: debug : lxcControllerMain:380 : EPOLLHUP from fd 7
-----END
i've tried endless variations of the <devices> section, but i just
cant seem to get anything going with libvirt/LXC once i move the root
to a new location for a system container. same container works fine
with lxc-* tools (although i manually make a bridge). any help is
appreciated,
C Anthony Risinger
15 years
[libvirt] Synchronous commands block virsh?
by Matthew Richardson
I'm currently playing with libvirt on Ubuntu 9.10:
Compiled against library: libvir 0.7.0
Using library: libvir 0.7.0
Using API: QEMU 0.7.0
Running hypervisor: QEMU 0.11.0
I've noticed that if I open virsh on a host and set a live migration
going, then virsh doesn't return until the migration is complete.
However, if I open a second virsh command, it too blocks on commands
(e.g list), meaning that I can't perform any other operations against
other domains until the initial migration is complete.
Is this deliberate or accidental? Is there any way round this?
Thanks,
Matthew
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
15 years
[libvirt] [PATCH] vbox: Use virIndexToDiskName() in vboxGenerateMediumName()
by Matthias Bolte
---
src/vbox/vbox_tmpl.c | 48 +++++++++---------------------------------------
1 files changed, 9 insertions(+), 39 deletions(-)
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 10cc1ed..33f5334 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -426,15 +426,14 @@ static void vboxUtf8toIID(virConnectPtr conn, char *uuidstr, vboxIID **iid) {
* @param aMaxSlotPerPort Input array of max slot per device port
*
*/
-static char *vboxGenerateMediumName(virConnectPtr conn,
- PRUint32 storageBus,
+static char *vboxGenerateMediumName(PRUint32 storageBus,
PRInt32 deviceInst,
PRInt32 devicePort,
PRInt32 deviceSlot,
PRUint32 *aMaxPortPerInst,
PRUint32 *aMaxSlotPerPort) {
+ const char *prefix = NULL;
char *name = NULL;
- int len = 0;
int total = 0;
PRUint32 maxPortPerInst = 0;
PRUint32 maxSlotPerPort = 0;
@@ -453,48 +452,20 @@ static char *vboxGenerateMediumName(virConnectPtr conn,
+ (devicePort * maxSlotPerPort)
+ deviceSlot;
- if ((total >= 0) && (total < 26))
- len = 4;
- else if ((total >= 26) && (total < 26*26 + 26))
- len = 5;
- else if ((total >= 26*26 + 26) && (total < 26*26*26 + 26*26 + 26))
- len = 6;
- else
- return NULL;
-
- if (VIR_ALLOC_N(name, len) < 0) {
- virReportOOMError(conn);
- return NULL;
- }
-
- /* TODO: use virIndexToDiskName() here when available */
if (storageBus == StorageBus_IDE) {
- name[0] = 'h';
- name[1] = 'd';
+ prefix = "hd";
} else if ( (storageBus == StorageBus_SATA)
|| (storageBus == StorageBus_SCSI)) {
- name[0] = 's';
- name[1] = 'd';
+ prefix = "sd";
} else if (storageBus == StorageBus_Floppy) {
- name[0] = 'f';
- name[1] = 'd';
+ prefix = "fd";
}
- if (len == 4) {
- name[2] = (char)(97 + total);
- } else if (len == 5) {
- name[2] = (char)(96 + (total / 26));
- name[3] = (char)(97 + (total % 26));
- } else if (len == 6) {
- name[2] = (char)(96 + (total / 26*26));
- name[3] = (char)(96 + ((total % (26*26)) / 26));
- name[4] = (char)(97 + ((total % (26*26)) % 26));
- }
+ name = virIndexToDiskName(total, prefix);
- name[len - 1] = '\0';
- DEBUG("name=%s, len=%d, total=%d, storageBus=%u, deviceInst=%d, "
+ DEBUG("name=%s, total=%d, storageBus=%u, deviceInst=%d, "
"devicePort=%d deviceSlot=%d, maxPortPerInst=%u maxSlotPerPort=%u",
- name, len, total, storageBus, deviceInst, devicePort,
+ NULLSTR(name), total, storageBus, deviceInst, devicePort,
deviceSlot, maxPortPerInst, maxSlotPerPort);
return name;
}
@@ -2496,8 +2467,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
imediumattach->vtbl->GetPort(imediumattach, &devicePort);
imediumattach->vtbl->GetDevice(imediumattach, &deviceSlot);
- def->disks[diskCount]->dst = vboxGenerateMediumName(dom->conn,
- storageBus,
+ def->disks[diskCount]->dst = vboxGenerateMediumName(storageBus,
deviceInst,
devicePort,
deviceSlot,
--
1.6.0.4
15 years
[libvirt] [PATCH] Export all symbols from xml.h for internal use
by Jiri Denemark
Some of the very useful calls for XML parsing provided by util/xml.[ch]
were not exported as private symbols. This patch fixes this.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/libvirt_private.syms | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index edac3bc..0e53063 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -543,3 +543,9 @@ virXPathNodeSet;
virXPathString;
virXMLPropString;
virXPathStringLimit;
+virXPathBoolean;
+virXPathNumber;
+virXPathULong;
+virXPathULongLong;
+virXPathLongHex;
+virXPathULongHex;
--
1.6.5.4
15 years
[libvirt] [PATCH 0/2] Xen: Add support for interface model='netfront'
by Jiri Denemark
Xen HVM guests with PV drivers end up with two network interfaces for
each configured interface. One of them being emulated by qemu and the
other one paravirtual. As this might not be desirable, the attached
patch provides a way for users to specify that only paravirtual network
interface should be presented to the guest.
The configuration was inspired by qemu/kvm driver, for which users can
specify model='virtio' to use paravirtual network interface.
The patch adds support for model='netfront' which results in
type=netfront instead of type=ioemu (or nothing for newer xen versions)
in guests native configuration. Xen's qemu ignores interfaces with
type != ioemu and only paravirtual network device will be seen in the
guest.
Four possible configuration scenarios follow:
- no model specified in domain's XML
- libvirt will behave like before this change; it will set
type=ioemu for HVM guests on xen host which is not newer than
XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU
- covered by existing tests
- PV guest, any model
- no functional change, model is passed as is (and ignored by the
hypervisor)
- covered by existing tests (e.g., *-net-e1000.*)
- HVM guest, model=netfront
- type is set to "netfront", model is not specified
- covered by new *-net-netfront.* tests
- HVM guest, model != netfront
- type is set to "ioemu", model is passed as is
- covered by new *-net-ioemu.* tests
The fourth scenario feels like a regression for xen newer than
XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU as users who had a model specified
in their guest's configuration won't see a paravirtual interface in
their guests any more. On the other hand, the reason for specifying a
model is most likely the fact that they want to use such model which
implies emulated interface. Users of older xen won't be affected at all
as their xen provides paravirtual interface regardless of the type used.
In previous version of this patch, I used "xenpv" instead of "netfront"
as it looked more like kvm/qemu's virtio. However, you can find several
tips how to force PV network interface for HVM guest by using
type="netfront" so I changed it to conform with those tips. It also
matches guest's driver name used for that device.
Jiri Denemark (2):
Support for interface model='netfront'
Tests for interface type/model configuration
src/xen/xend_internal.c | 32 +++++++++++----
src/xen/xm_internal.c | 38 +++++++++++++++--
tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.sexpr | 1 +
tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.xml | 42 +++++++++++++++++++
.../sexpr2xmldata/sexpr2xml-fv-net-netfront.sexpr | 1 +
tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml | 42 +++++++++++++++++++
tests/sexpr2xmltest.c | 3 +
tests/xmconfigdata/test-fullvirt-net-ioemu.cfg | 25 +++++++++++
tests/xmconfigdata/test-fullvirt-net-ioemu.xml | 43 ++++++++++++++++++++
tests/xmconfigdata/test-fullvirt-net-netfront.cfg | 25 +++++++++++
tests/xmconfigdata/test-fullvirt-net-netfront.xml | 43 ++++++++++++++++++++
tests/xmconfigtest.c | 3 +
tests/xml2sexprdata/xml2sexpr-fv-net-ioemu.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-net-ioemu.xml | 31 ++++++++++++++
.../xml2sexprdata/xml2sexpr-fv-net-netfront.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-net-netfront.xml | 31 ++++++++++++++
tests/xml2sexprtest.c | 3 +
17 files changed, 352 insertions(+), 13 deletions(-)
create mode 100644 tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.sexpr
create mode 100644 tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.xml
create mode 100644 tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.sexpr
create mode 100644 tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml
create mode 100644 tests/xmconfigdata/test-fullvirt-net-ioemu.cfg
create mode 100644 tests/xmconfigdata/test-fullvirt-net-ioemu.xml
create mode 100644 tests/xmconfigdata/test-fullvirt-net-netfront.cfg
create mode 100644 tests/xmconfigdata/test-fullvirt-net-netfront.xml
create mode 100644 tests/xml2sexprdata/xml2sexpr-fv-net-ioemu.sexpr
create mode 100644 tests/xml2sexprdata/xml2sexpr-fv-net-ioemu.xml
create mode 100644 tests/xml2sexprdata/xml2sexpr-fv-net-netfront.sexpr
create mode 100644 tests/xml2sexprdata/xml2sexpr-fv-net-netfront.xml
15 years