[libvirt] [PATCH] Fix generating python bindings
by Cole Robinson
The recent API additions virSaveLastError and virFreeError upset the
python bindings generator. Add a rule to explicitly skip them for the
bindings, since (as far as I can tell) the libvirtError class provides
everything we need.
Thanks,
Cole
15 years, 10 months
[libvirt] [PATCH] Fix virsh {net,pool}-edit
by Cole Robinson
The dumpxml commands for networks and pools don't support any flag
arguments, and in fact explictly fail if flags != 0. This is not the
case for vm dumpxml though, and flags were added to the base 'edit'
implementation in virsh recently.
The net and pool derivatives were not addressing this difference, so any
net-edit or pool-edit attempt currently gives an error like:
Network error : invalid argument in virNetworkGetXMLDesc
The attached patch is one way to fix this. Thanks to Charles Duffy for
the report.
- Cole
15 years, 10 months
[libvirt] Per-VM access control
by Jan Kasprzak
Hello,
is it possible to run libvirt as a "hosting-like" environment?
we would like to provide virtual machines for our users, but we would
like them to be able to reset/reboot/poweroff only their own VMs,
connect to the serial console of their own VMs only, and even maybe
connect to the graphical console of their own VMs.
Is it possible with libvirt, and without giving them shell access
to the hosting machine?
For the serial console, I thought about creating a ssh-only
account with hardcoded "virsh console <their_machine_name>" command,
but "virsh console" can be escaped from using ^], so this is not secure
- this way they would be able to get access to other VMs as well.
Thanks,
-Yenya
--
| Jan "Yenya" Kasprzak <kas at {fi.muni.cz - work | yenya.net - private}> |
| GPG: ID 1024/D3498839 Fingerprint 0D99A7FB206605D7 8B35FCDE05B18A5E |
| http://www.fi.muni.cz/~kas/ Journal: http://www.fi.muni.cz/~kas/blog/ |
>> If you find yourself arguing with Alan Cox, you’re _probably_ wrong. <<
>> --James Morris in "How and Why You Should Become a Kernel Hacker" <<
15 years, 10 months
[libvirt] Compilation Errors
by Russell
I'm trying to compile libvirt 0.6.0 on Gentoo, but keep encountering
the following error:
network_driver.c:72: error: expected specifier-qualifier-list before 'brControl'
network_driver.c: In function 'networkFindActiveConfigs':
<snip - just a bunch of 'struct network_driver' has no member named * >
network_driver.c:1382: error: 'struct network_driver' has no member
named 'networkConfigDir'
network_driver.c:1384: error: 'struct network_driver' has no member
named 'networkAutostartDir'
network_driver.c:1390: error: 'struct network_driver' has no member
named 'networkAutostartDir'
network_driver.c:1391: error: 'struct network_driver' has no member
named 'networkAutostartDir'
make[3]: *** [network_driver.lo] Error 1
make[3]: Leaving directory `/home/russell/libvirt/libvirt-0.6.0/src'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/russell/libvirt/libvirt-0.6.0/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/russell/libvirt/libvirt-0.6.0'
make: *** [all] Error 2
Every error following the first one refers to networkConfigDir,
networkAutostartDir, or logDir, all listed after brControl in the
definition of network_driver.
What looks to me like the same error has been reported against 0.5.1
here (I haven't tried it myself):
http://bugs.gentoo.org/show_bug.cgi?id=254568
My configuration options:
./configure --prefix=/usr --host=i686-pc-linux-gnu
--mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share
--sysconfdir=/etc --localstatedir=/var/lib --with-avahi
--without-storage-iscsi --without-storage-lvm --without-lxc --with-hal
--without-openvz --without-storage-disk --without-sasl
--without-selinux --without-uml --without-xen --without-qemu
--without-devkit --without-polkit --with-remote
--disable-iptables-lokkit --localstatedir=/var
--with-remote-pid-file=/var/run/libvirtd.pid --build=i686-pc-linux-gnu
If other info would help resolve this I'd be happy to try and provide it.
Thanks,
--
Russell Haering
System Administrator
OSU Open Source Lab
15 years, 10 months
[libvirt] [PATCH] Allow off-line removal of devices via xend
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1233765613 28800
# Node ID bda41ea0cbbdea409447686c30b7afb10b9cae85
# Parent e6b17082b9b9440ce14ad76bd2f4c003ae2404db
Allow off-line removal of devices via xend
We must avoid xenstore if the domain isn't running. For disks, this
works in all xend versions; for NICs, however, this requires a change in
netif.py to allow matching by MAC address. Preferring the device ID but
falling back to the device ref works best with all versions of xend.
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/src/xend_internal.c b/src/xend_internal.c
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -92,11 +92,17 @@ xenDaemonFormatSxprNet(virConnectPtr con
int xendConfigVersion,
int isAttach);
static int
-virDomainXMLDevID(virDomainPtr domain,
- virDomainDeviceDefPtr dev,
- char *class,
- char *ref,
- int ref_len);
+virDomainDevRef(virDomainPtr domain,
+ virDomainDeviceDefPtr dev,
+ char *class,
+ char *ref,
+ int ref_len);
+static int
+virDomainDevID(virDomainPtr domain,
+ int type,
+ const char *ref,
+ char *devid,
+ int devid_len);
#endif
#define virXendError(conn, code, fmt...) \
@@ -3857,7 +3863,7 @@ xenDaemonAttachDevice(virDomainPtr domai
virDomainDeviceDefPtr dev = NULL;
virDomainDefPtr def = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
- char class[8], ref[80];
+ char class[8], ref[80], devid[80];
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
@@ -3913,15 +3919,24 @@ xenDaemonAttachDevice(virDomainPtr domai
sexpr = virBufferContentAndReset(&buf);
- if (virDomainXMLDevID(domain, dev, class, ref, sizeof(ref))) {
+ devid[0] = '\0';
+
+ if (virDomainDevRef(domain, dev, class, ref, sizeof(ref)) == -1)
+ goto cleanup;
+
+ if (domain->id > 0 &&
+ virDomainDevID(domain, dev->type, ref, devid, sizeof(devid)) != -1) {
+ VIR_DEBUG("device_configure(ref = %s, devid = %s): %s",
+ ref, devid, sexpr);
+ /* device exists, attempt to modify it */
+ ret = xend_op(domain->conn, domain->name, "op", "device_configure",
+ "config", sexpr, "dev", devid, NULL);
+ } else {
+ VIR_DEBUG("device_create(ref = %s, devid = %s): %s",
+ ref, devid, sexpr);
/* device doesn't exist, define it */
ret = xend_op(domain->conn, domain->name, "op", "device_create",
"config", sexpr, NULL);
- }
- else {
- /* device exists, attempt to modify it */
- ret = xend_op(domain->conn, domain->name, "op", "device_configure",
- "config", sexpr, "dev", ref, NULL);
}
cleanup:
@@ -3944,7 +3959,7 @@ xenDaemonDetachDevice(virDomainPtr domai
xenDaemonDetachDevice(virDomainPtr domain, const char *xml)
{
xenUnifiedPrivatePtr priv;
- char class[8], ref[80];
+ char class[8], ref[80], devid[80];
virDomainDeviceDefPtr dev = NULL;
virDomainDefPtr def = NULL;
int ret = -1;
@@ -3975,11 +3990,40 @@ xenDaemonDetachDevice(virDomainPtr domai
def, xml, VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
- if (virDomainXMLDevID(domain, dev, class, ref, sizeof(ref)))
+ if (dev->type != VIR_DOMAIN_DEVICE_NET &&
+ dev->type != VIR_DOMAIN_DEVICE_DISK) {
+ virXendError(domain->conn, VIR_ERR_INTERNAL_ERROR,
+ _("can't detach device of type %d"), dev->type);
goto cleanup;
+ }
+
+ /*
+ * First acquire a static reference to the device (MAC address or
+ * destination disk). We'll use this if the domain isn't running,
+ * otherwise we'll rely upon the XenStore devid.
+ */
+
+ if (virDomainDevRef(domain, dev, class, ref, sizeof(ref)) == -1) {
+ virXendError(domain->conn, VIR_ERR_INTERNAL_ERROR,
+ _("can't detach device: not found "));
+ goto cleanup;
+ }
+
+ if (domain->id >= 0) {
+ if (virDomainDevID(domain, dev->type, ref, devid, sizeof(devid)))
+ virXendError(domain->conn, VIR_ERR_INTERNAL_ERROR,
+ _("can't detach device: not found "));
+ goto cleanup;
+ } else {
+ strncpy(devid, ref, 80);
+ }
+
+ VIR_DEBUG("device_destroy(type = %s, ref = %s, devid = %s)",
+ class, ref, devid);
ret = xend_op(domain->conn, domain->name, "op", "device_destroy",
- "type", class, "dev", ref, "force", "0", "rm_cfg", "1", NULL);
+ "type", class, "dev", devid, "force", "0",
+ "rm_cfg", "1", NULL);
cleanup:
virDomainDefFree(def);
@@ -5501,12 +5545,48 @@ error:
/**
- * virDomainXMLDevID:
+ * virDomainXMLDevRef:
* @domain: pointer to domain object
* @dev: pointer to device config object
* @class: Xen device class "vbd" or "vif" (OUT)
* @ref: Xen device reference (OUT)
*
+ * Return the class (vbd/vif) and reference (MAC address / disk
+ * destination) of the given device.
+ *
+ * Returns 0 in case of success, -1 in case of failure.
+ */
+static int
+virDomainDevRef(virDomainPtr domain,
+ virDomainDeviceDefPtr dev,
+ char *class,
+ char *ref,
+ int ref_len)
+{
+ if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
+ if (dev->data.disk->dst == NULL)
+ return -1;
+ strncpy(ref, dev->data.disk->dst, ref_len);
+ strcpy(class, "vbd");
+ } else if (dev->type == VIR_DOMAIN_DEVICE_NET) {
+ virFormatMacAddr(dev->data.net->mac, ref);
+ strcpy(class, "vif");
+ } else {
+ virXendError(NULL, VIR_ERR_NO_SUPPORT,
+ _("no support for device type %d"), dev->type);
+ return -1;
+ }
+
+ return 0;
+}
+
+/**
+ * virDomainXMLDevID:
+ * @domain: pointer to domain object
+ * @class: either 'vbd' or 'vif'
+ * @ref: Xen device reference
+ * @devid: Xen device ID (OUT)
+ *
* Set class according to XML root, and:
* - if disk, copy in ref the target name from description
* - if network, get MAC address from description, scan XenStore and
@@ -5515,54 +5595,41 @@ error:
* Returns 0 in case of success, -1 in case of failure.
*/
static int
-virDomainXMLDevID(virDomainPtr domain,
- virDomainDeviceDefPtr dev,
- char *class,
- char *ref,
- int ref_len)
+virDomainDevID(virDomainPtr domain,
+ int type,
+ const char *ref,
+ char *devid,
+ int devid_len)
{
xenUnifiedPrivatePtr priv = domain->conn->privateData;
- char *xref;
-
- if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
- strcpy(class, "vbd");
- if (dev->data.disk->dst == NULL)
- return -1;
- xenUnifiedLock(priv);
- xref = xenStoreDomainGetDiskID(domain->conn, domain->id,
- dev->data.disk->dst);
- xenUnifiedUnlock(priv);
- if (xref == NULL)
- return -1;
-
- strncpy(ref, xref, ref_len);
- free(xref);
- ref[ref_len - 1] = '\0';
- } else if (dev->type == VIR_DOMAIN_DEVICE_NET) {
- char mac[30];
- virDomainNetDefPtr def = dev->data.net;
- snprintf(mac, sizeof(mac), "%02x:%02x:%02x:%02x:%02x:%02x",
- def->mac[0], def->mac[1], def->mac[2],
- def->mac[3], def->mac[4], def->mac[5]);
-
- strcpy(class, "vif");
-
- xenUnifiedLock(priv);
- xref = xenStoreDomainGetNetworkID(domain->conn, domain->id,
- mac);
- xenUnifiedUnlock(priv);
- if (xref == NULL)
- return -1;
-
- strncpy(ref, xref, ref_len);
- free(xref);
- ref[ref_len - 1] = '\0';
+ char *id = NULL;
+
+ if (domain->id < 0) {
+ virXendError(domain->conn, VIR_ERR_INTERNAL_ERROR,
+ _("devid not available for shutdown domain"));
+ return -1;
+ }
+
+ xenUnifiedLock(priv);
+
+ if (type == VIR_DOMAIN_DEVICE_DISK) {
+ id = xenStoreDomainGetDiskID(domain->conn, domain->id, ref);
+
+ } else if (type == VIR_DOMAIN_DEVICE_NET) {
+ id = xenStoreDomainGetNetworkID(domain->conn, domain->id, ref);
} else {
virXendError(NULL, VIR_ERR_NO_SUPPORT,
- "%s", _("hotplug of device type not supported"));
+ _("no support for device type %d"), type);
+ }
+
+ xenUnifiedUnlock(priv);
+
+ if (id == NULL)
return -1;
- }
-
+
+ strncpy(devid, id, devid_len);
+ VIR_FREE(id);
+ devid[devid_len - 1] = '\0';
return 0;
}
15 years, 10 months
[libvirt] Libvirt /proc/cpuinfo processing fails on Linux/Sparc
by Richard W.M. Jones
Below is what /proc/cpuinfo looks like on an Ultrasparc T1 running
Linux.
I haven't looked into it in detail yet, but the report from Dennis
Gilmore is that this breaks every libvirt command. Presumably we are
parsing /proc/cpuinfo at libvirt startup ...
(Initially reported by Dennis Gilmore)
Rich.
cpu : UltraSparc T1 (Niagara)
fpu : UltraSparc T1 integrated FPU
prom : OBP 4.29.0.a 2008/09/15 11:59
type : sun4v
ncpus probed : 32
ncpus active : 32
D$ parity tl1 : 0
I$ parity tl1 : 0
Cpu0ClkTck : 000000003b9aca00
Cpu1ClkTck : 000000003b9aca00
Cpu2ClkTck : 000000003b9aca00
Cpu3ClkTck : 000000003b9aca00
Cpu4ClkTck : 000000003b9aca00
Cpu5ClkTck : 000000003b9aca00
Cpu6ClkTck : 000000003b9aca00
Cpu7ClkTck : 000000003b9aca00
Cpu8ClkTck : 000000003b9aca00
Cpu9ClkTck : 000000003b9aca00
Cpu10ClkTck : 000000003b9aca00
Cpu11ClkTck : 000000003b9aca00
Cpu12ClkTck : 000000003b9aca00
Cpu13ClkTck : 000000003b9aca00
Cpu14ClkTck : 000000003b9aca00
Cpu15ClkTck : 000000003b9aca00
Cpu16ClkTck : 000000003b9aca00
Cpu17ClkTck : 000000003b9aca00
Cpu18ClkTck : 000000003b9aca00
Cpu19ClkTck : 000000003b9aca00
Cpu20ClkTck : 000000003b9aca00
Cpu21ClkTck : 000000003b9aca00
Cpu22ClkTck : 000000003b9aca00
Cpu23ClkTck : 000000003b9aca00
Cpu24ClkTck : 000000003b9aca00
Cpu25ClkTck : 000000003b9aca00
Cpu26ClkTck : 000000003b9aca00
Cpu27ClkTck : 000000003b9aca00
Cpu28ClkTck : 000000003b9aca00
Cpu29ClkTck : 000000003b9aca00
Cpu30ClkTck : 000000003b9aca00
Cpu31ClkTck : 000000003b9aca00
MMU Type : Hypervisor (sun4v)
State:
CPU0: online
CPU1: online
CPU2: online
CPU3: online
CPU4: online
CPU5: online
CPU6: online
CPU7: online
CPU8: online
CPU9: online
CPU10: online
CPU11: online
CPU12: online
CPU13: online
CPU14: online
CPU15: online
CPU16: online
CPU17: online
CPU18: online
CPU19: online
CPU20: online
CPU21: online
CPU22: online
CPU23: online
CPU24: online
CPU25: online
CPU26: online
CPU27: online
CPU28: online
CPU29: online
CPU30: online
CPU31: online
--
Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
15 years, 10 months
[libvirt] Libvirt for RHEL4 update4
by Gavin Gong
Hi Guys,
We are eagerly trying to deploy libvirt on a production environment
based on RHEL4 U4, but unfortunately it seems that for RHEL this API is
only available for version5, we can't find any libvirt packages for
RHEL4 U4, can you give us some advise for this situation? Thanks.
Gavin
Gavin Gong
3rd Line Engineer - Server/Database Technology
DD:
+44(0) 207 517 6581
M:
+44(0) 7982 132 869
T:
+44(0) 845 459 1111
F:
+44(0) 207 517 6501
E:
gavin.gong(a)controlcircle.com <mailto:gavin.gong@controlcircle.com>
Data Storage Network Security
Moorfoot House, 221 Marsh Wall
Managed Connectivity Dedicated Hosting
London E14 9FH
Managed Services
http://www.controlcircle.com <http://www.controlcircle.com/>
Click here
<http://www.controlcircle.com/ProductsNServices/Email-Privacy-and-confid
entiality-statement> to view our privacy & confidentiality statement
P Please don't print this e-mail unless you really need to.
15 years, 10 months
[libvirt] [PATCH] Fix migration for 3.3 xend
by John Levon
# HG changeset patch
# User John Levon <john.levon(a)sun.com>
# Date 1234535031 28800
# Node ID 3b0d2047df2c53ff2994d2bff4b1123110626ee2
# Parent 0c02b55855c7a3bfa1135887ffb1763ef29179e5
Fix migration for 3.3 xend
xend grew a couple of new options for the migration method. As they're
ignored on older xend versions, always pass them.
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/src/xend_internal.c b/src/xend_internal.c
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -4292,6 +4292,8 @@ xenDaemonDomainMigratePerform (virDomain
"destination", hostname,
"live", live,
"port", port,
+ "node", "-1",
+ "ssl", "0",
"resource", "0", /* required, xend ignores it */
NULL);
VIR_FREE (hostname);
15 years, 10 months
[libvirt] [PATCH 0/3] Fix aliasing rules warnings with gcc-4.4
by Mark McLoughlin
Hi,
It seems gcc's strict aliasing rules got stricter with gcc-4.4.
The basic rule is that two pointers of different types can't be
used to reference the same address in memory. One exception is
using a char* and another is when different types are members
of a union.
I've used unions to fix all the warnings I see with current
CVS HEAD. I can't say I like the solution all that much, so
if anyone has better ideas ...
Cheers,
Mark.
15 years, 10 months