[libvirt] Multpile network interfaces have same MAC address
by David Mueller
I remember seeing this problem before, but I can't remember what the
resolution was, nor can I find a discussion of the issue in
the list archives or Bugzilla.
I've had my setup working for a while now, on both Fedora 8 and Fedora 10.
Now I'm trying to get it to work with CentOS 5 and
running into an old bug. My guest VM has multiple virtual network
interfaces, with the MAC address defined in the XML file used to
define the VM. However, I'm seeing each network interface getting the
same MAC addrss (the last one defined in the XML file) on
all if the interfaces when I run ifconfig in the guest.
Was there a workaround for this, or do I need to upgrade libvirt? CentOS
5.2 is what I'm working with; they haven't released 5.3
yet so I don't know if that will have a newer version.
# rpm -qa libvirt
libvirt-0.3.3-7.el5
# virsh version
Compiled against library: libvir 0.3.3
Using library: libvir 0.3.3
Using API: QEMU 0.3.3
Running hypervisor: QEMU 0.9.1
- David
15 years, 7 months
Re: [libvirt] libvirt 0.3.3 and unix_sock_group
by Daniel Labrosse
Thanks for getting back to me. The permissions on that directory look ok
to me, see below (cadc is the group specified in my libvirtd.conf).
Which leads me to think it could be something else.
labrosse@proc5-09$ ls -la /var/run/libvirt
total 16
drwxr-xr-x 2 root root 4096 Apr 15 03:25 .
drwxr-xr-x 21 root root 4096 Apr 15 04:02 ..
srwxrwx--- 1 root cadc 0 Apr 15 03:25 libvirt-sock
srwxrwxrwx 1 root cadc 0 Apr 15 03:25 libvirt-sock-ro
labrosse@proc5-09$ ls -l /var/run/libvirt/libvirt-sock
srwxrwx--- 1 root cadc 0 Apr 15 03:25 /var/run/libvirt/libvirt-sock
It seems as if its xen causing the issue (although i cannot see any
issues in the logs). I get a 'Xen Daemon error' when connecting as my
user. I have verified the xen daemon is running and I can sudo virsh
list without seeing any errors.
> labrosse@proc5-09$ virsh list
> libvir: Xen Daemon error : internal error failed to connect to xend
> libvir: Xen Daemon error : internal error failed to connect to xend
> Id Name State
> ----------------------------------
> 0 Domain-0 running
> 7 1-d462220a-8dfe-4b7b-b853-a89f3cac2d46 blocked
>
> labrosse@proc5-09$ sudo virsh list
> Id Name State
> ----------------------------------
> 0 Domain-0 running
> 7 1-d462220a-8dfe-4b7b-b853-a89f3cac2d46 blocked
>
Are you aware of any other configuration that needs to be done elsewhere?
thanks
Daniel
On Wed, 2009-04-15 at 10:08 +0100, Daniel P. Berrange wrote:
> On Tue, Apr 14, 2009 at 02:06:52PM -0700, Daniel Labrosse wrote:
> > Hi All,
> >
> > I've been using libvirt 0..4.4 for a few weeks now. I have
> > unix_sock_group = "mygroup" set so that i can perform non-root
> > management capabilities on the host.
> >
> > I have recently installed a new host running Scientific Linux 5.3 and
> > libvirt 0.3.3 comes as default. First off, there is no libvirtd.conf
> > file included with 0.3.3, so I copied the file from libvirt 0.4.4 (which
> > is running on my Fedora 8 box).
>
> The 'unix_sock_group' config param *is* supported in 0.3.3, but the
> libvirtd daemon will not change the group ownership in the directory
> /var/run/libvirt where the socket is created. So you almost certainly
> won't be able to access the socket itself. You could try chgrp'ing the
> directory. A good test is to make sure you can access the socket as
> non-root, eg
>
> ls -l /var/run/libvirt/libvirt-sock
>
>
> Daniel
15 years, 7 months
[libvirt] libvirt 0.6.2 on Fedora 10
by Thomas Sjolshagen
I've been looking for a binary package for x86_64/fc10 of
libvirt/libvirt-python, but can only find the F11 versions.
Have none been created and I'll need to build my own, or am I (and
google/rpmfind/koji/etc) being vision impaired?
Thanks,
// Thomas
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
15 years, 7 months
[libvirt] VirtualBox libvirt support sample XML file
by Pritesh Kothari
Hi All,
Just posting a sample XML file for creating a machine with all features
supported by the patch, so that it is easy for everyone to know which
features are supported till now, I am in process of adding the
Documentation for same and thus posting this file till then.
Regards
Pritesh
15 years, 7 months
[libvirt] [PATCH][take2][1/2] add virGetUIDByUsername() and virGetGIDByGroupname()
by Ryota Ozaki
Signed-off-by: Ryota Ozaki <ozaki.ryota(a)gmail.com>
>From de8c57e3a2c4e564ec989016c547ad6754e43871 Mon Sep 17 00:00:00 2001
From: Ryota Ozaki <ozaki.ryota(a)gmail.com>
Date: Wed, 8 Apr 2009 23:10:46 +0900
Subject: [PATCH] add virGetUIDByUsername() and virGetGIDByGroupname()
---
configure.in | 2 +-
src/util.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
src/util.h | 8 ++++++++
3 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/configure.in b/configure.in
index ac2c89e..2ae15e3 100644
--- a/configure.in
+++ b/configure.in
@@ -75,7 +75,7 @@ dnl Availability of various common functions
(non-fatal if missing).
AC_CHECK_FUNCS([cfmakeraw regexec uname sched_getaffinity getuid
getgid posix_fallocate mmap readlink])
dnl Availability of various not common threadsafe functions
-AC_CHECK_FUNCS([strerror_r strtok_r getmntent_r getgrnam_r getpwuid_r])
+AC_CHECK_FUNCS([strerror_r strtok_r getmntent_r getgrnam_r getpwuid_r
getpwnam_r])
dnl Availability of various common headers (non-fatal if missing).
AC_CHECK_HEADERS([pwd.h paths.h regex.h sys/syslimits.h sys/utsname.h
sys/wait.h winsock2.h sched.h termios.h sys/poll.h syslog.h])
diff --git a/src/util.c b/src/util.c
index 5abdbbc..b939282 100644
--- a/src/util.c
+++ b/src/util.c
@@ -53,9 +53,12 @@
#include <paths.h>
#endif
#include <netdb.h>
-#ifdef HAVE_GETPWUID_R
+#if defined(HAVE_GETPWUID_R) || defined(HAVE_GETPWNAM_R)
#include <pwd.h>
#endif
+#ifdef HAVE_GETGRNAM_R
+#include <grp.h>
+#endif
#include "virterror_internal.h"
#include "logging.h"
@@ -1686,3 +1689,55 @@ char *virGetUserDirectory(virConnectPtr conn,
return ret;
}
#endif
+
+
+#ifdef HAVE_GETPWNAM_R
+int virGetUIDByUsername(virConnectPtr conn, char *name)
+{
+ struct passwd pwbuf;
+ struct passwd *pw = NULL;
+ char *strbuf;
+ size_t strbuflen = sysconf(_SC_GETPW_R_SIZE_MAX);
+
+ if (VIR_ALLOC_N(strbuf, strbuflen) < 0) {
+ virReportOOMError(conn);
+ return -1;
+ }
+
+ if (getpwnam_r(name, &pwbuf, strbuf, strbuflen, &pw) != 0 || pw == NULL) {
+ virReportSystemError(conn, errno,
+ _("Failed to find user record for name '%s'"),
+ name);
+ VIR_FREE(strbuf);
+ return -1;
+ }
+ VIR_FREE(strbuf);
+ return pw->pw_uid;
+}
+#endif
+
+
+#ifdef HAVE_GETGRNAM_R
+int virGetGIDByGroupname(virConnectPtr conn, char *name)
+{
+ struct group grbuf;
+ struct group *gr = NULL;
+ char *strbuf;
+ size_t strbuflen = sysconf(_SC_GETGR_R_SIZE_MAX);
+
+ if (VIR_ALLOC_N(strbuf, strbuflen) < 0) {
+ virReportOOMError(conn);
+ return -1;
+ }
+
+ if (getgrnam_r(name, &grbuf, strbuf, strbuflen, &gr) != 0 || gr == NULL) {
+ virReportSystemError(conn, errno,
+ _("Failed to find group record for name '%s'"),
+ name);
+ VIR_FREE(strbuf);
+ return -1;
+ }
+ VIR_FREE(strbuf);
+ return gr->gr_gid;
+}
+#endif
diff --git a/src/util.h b/src/util.h
index 6fe03b6..0f75439 100644
--- a/src/util.h
+++ b/src/util.h
@@ -199,6 +199,14 @@ char *virGetUserDirectory(virConnectPtr conn,
uid_t uid);
#endif
+#ifdef HAVE_GETPWNAM_R
+int virGetUIDByUsername(virConnectPtr conn, char *name);
+#endif
+
+#ifdef HAVE_GETGRNAM_R
+int virGetGIDByGroupname(virConnectPtr conn, char *name);
+#endif
+
int virRandomInitialize(unsigned int seed);
int virRandom(int max);
--
1.6.0.6
15 years, 7 months
[libvirt] [PATCH][take2][2/2] storage: allow alphabetical names in owner/group of permissions
by Ryota Ozaki
Signed-off-by: Ryota Ozaki <ozaki.ryota(a)gmail.com>
>From c441d5f29f1ed964e3c17dcac8614c0834eaba49 Mon Sep 17 00:00:00 2001
From: Ryota Ozaki <ozaki.ryota(a)gmail.com>
Date: Thu, 16 Apr 2009 23:17:29 +0900
Subject: [PATCH] storage: allow alphabetical names in owner/group of permissions
---
docs/schemas/storagepool.rng | 10 ++++-
docs/schemas/storagevol.rng | 10 ++++-
src/Makefile.am | 1 +
src/storage_backend.c | 8 +++-
src/storage_backend_fs.c | 32 ++++++++++++++-
src/storage_backend_logical.c | 33 ++++++++++++++-
src/storage_conf.c | 91 +++++++++++++++++++++++++++++------------
src/storage_conf.h | 4 +-
8 files changed, 152 insertions(+), 37 deletions(-)
diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng
index e152e19..ed1e597 100644
--- a/docs/schemas/storagepool.rng
+++ b/docs/schemas/storagepool.rng
@@ -127,10 +127,16 @@
<ref name='uint'/>
</element>
<element name='owner'>
- <ref name='uint'/>
+ <choice>
+ <ref name='uint'/>
+ <ref name='name'/>
+ </choice>
</element>
<element name='group'>
- <ref name='uint'/>
+ <choice>
+ <ref name='uint'/>
+ <ref name='name'/>
+ </choice>
</element>
<optional>
<element name='label'>
diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng
index c7bd3a7..13e08b5 100644
--- a/docs/schemas/storagevol.rng
+++ b/docs/schemas/storagevol.rng
@@ -46,10 +46,16 @@
<ref name='uint'/>
</element>
<element name='owner'>
- <ref name='uint'/>
+ <choice>
+ <ref name='uint'/>
+ <ref name='name'/>
+ </choice>
</element>
<element name='group'>
- <ref name='uint'/>
+ <choice>
+ <ref name='uint'/>
+ <ref name='name'/>
+ </choice>
</element>
<optional>
<element name='label'>
diff --git a/src/Makefile.am b/src/Makefile.am
index f176b46..84567aa 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -333,6 +333,7 @@ endif
# Needed to keep automake quiet about conditionals
libvirt_driver_storage_la_SOURCES =
+libvirt_driver_storage_la_LIBADD = libvirt_util.la
if WITH_STORAGE_DIR
if WITH_DRIVER_MODULES
mod_LTLIBRARIES += libvirt_driver_storage.la
diff --git a/src/storage_backend.c b/src/storage_backend.c
index b154140..810c4b5 100644
--- a/src/storage_backend.c
+++ b/src/storage_backend.c
@@ -214,8 +214,12 @@ virStorageBackendUpdateVolTargetInfoFD(virConnectPtr conn,
}
target->perms.mode = sb.st_mode & S_IRWXUGO;
- target->perms.uid = sb.st_uid;
- target->perms.gid = sb.st_gid;
+ VIR_FREE(target->perms.owner);
+ if (virAsprintf(&target->perms.owner, "%d", sb.st_uid) == -1)
+ return -1;
+ VIR_FREE(target->perms.group);
+ if (virAsprintf(&target->perms.group, "%d", sb.st_gid) == -1)
+ return -1;
VIR_FREE(target->perms.label);
diff --git a/src/storage_backend_fs.c b/src/storage_backend_fs.c
index 5000f43..d48c278 100644
--- a/src/storage_backend_fs.c
+++ b/src/storage_backend_fs.c
@@ -1189,7 +1189,37 @@ virStorageBackendFileSystemVolCreate(virConnectPtr conn,
/* We can only chown/grp if root */
if (getuid() == 0) {
- if (fchown(fd, vol->target.perms.uid, vol->target.perms.gid) < 0) {
+ int uid = 0, gid = 0;
+ char *owner = vol->target.perms.owner;
+ char *group = vol->target.perms.group;
+
+ if (owner) {
+ char *end = NULL;
+ int id = strtol(owner, &end, 10);
+ if (*end || id < 0) {
+ id = virGetUIDByUsername(conn, owner);
+ if (id < 0) {
+ unlink(vol->target.path);
+ close(fd);
+ return -1;
+ }
+ }
+ uid = id;
+ }
+ if (group) {
+ char *end = NULL;
+ int id = strtol(group, &end, 10);
+ if (*end || id < 0) {
+ id = virGetUIDByUsername(conn, group);
+ if (id < 0) {
+ unlink(vol->target.path);
+ close(fd);
+ return -1;
+ }
+ }
+ gid = id;
+ }
+ if (fchown(fd, uid, gid) < 0) {
virReportSystemError(conn, errno,
_("cannot set file owner '%s'"),
vol->target.path);
diff --git a/src/storage_backend_logical.c b/src/storage_backend_logical.c
index cbd2765..7a869f6 100644
--- a/src/storage_backend_logical.c
+++ b/src/storage_backend_logical.c
@@ -615,7 +615,38 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn,
/* We can only chown/grp if root */
if (getuid() == 0) {
- if (fchown(fd, vol->target.perms.uid, vol->target.perms.gid) < 0) {
+ int uid = 0, gid = 0;
+ char *owner = vol->target.perms.owner;
+ char *group = vol->target.perms.group;
+
+ if (owner) {
+ char *end = NULL;
+ int id = strtol(owner, &end, 10);
+ if (*end || id < 0) {
+ id = virGetUIDByUsername(conn, owner);
+ if (id < 0) {
+ unlink(vol->target.path);
+ close(fd);
+ return -1;
+ }
+ }
+ uid = id;
+ }
+ if (group) {
+ char *end = NULL;
+ int id = strtol(group, &end, 10);
+ if (*end || id < 0) {
+ id = virGetUIDByUsername(conn, group);
+ if (id < 0) {
+ unlink(vol->target.path);
+ close(fd);
+ return -1;
+ }
+ }
+ gid = id;
+ }
+
+ if (fchown(fd, uid, gid) < 0) {
virReportSystemError(conn, errno,
_("cannot set file owner '%s'"),
vol->target.path);
diff --git a/src/storage_conf.c b/src/storage_conf.c
index 9e25ccb..fd34319 100644
--- a/src/storage_conf.c
+++ b/src/storage_conf.c
@@ -256,8 +256,12 @@ virStorageVolDefFree(virStorageVolDefPtr def) {
VIR_FREE(def->source.extents);
VIR_FREE(def->target.path);
+ VIR_FREE(def->target.perms.owner);
+ VIR_FREE(def->target.perms.group);
VIR_FREE(def->target.perms.label);
VIR_FREE(def->backingStore.path);
+ VIR_FREE(def->backingStore.perms.owner);
+ VIR_FREE(def->backingStore.perms.group);
VIR_FREE(def->backingStore.perms.label);
VIR_FREE(def);
}
@@ -295,6 +299,8 @@ virStoragePoolDefFree(virStoragePoolDefPtr def) {
virStoragePoolSourceFree(&def->source);
VIR_FREE(def->target.path);
+ VIR_FREE(def->target.perms.owner);
+ VIR_FREE(def->target.perms.group);
VIR_FREE(def->target.perms.label);
VIR_FREE(def);
}
@@ -391,15 +397,14 @@ virStorageDefParsePerms(virConnectPtr conn,
xmlNodePtr relnode;
xmlNodePtr node;
+ perms->mode = defaultmode;
+ perms->owner = NULL;
+ perms->group = NULL;
+ perms->label = NULL;
+
node = virXPathNode(conn, permxpath, ctxt);
- if (node == NULL) {
- /* Set default values if there is not <permissions> element */
- perms->mode = defaultmode;
- perms->uid = getuid();
- perms->gid = getgid();
- perms->label = NULL;
+ if (node == NULL)
return 0;
- }
relnode = ctxt->node;
ctxt->node = node;
@@ -420,25 +425,53 @@ virStorageDefParsePerms(virConnectPtr conn,
}
if (virXPathNode(conn, "./owner", ctxt) == NULL) {
- perms->uid = getuid();
- } else {
- if (virXPathLong(conn, "number(./owner)", ctxt, &v) < 0) {
- virStorageReportError(conn, VIR_ERR_XML_ERROR,
- "%s", _("malformed owner element"));
+ if (virAsprintf(&perms->owner, "%d", getuid()) == -1) {
+ ret = -ENOMEM;
goto error;
}
- perms->uid = (int)v;
+ } else {
+ if (virXPathLong(conn, "number(./owner)", ctxt, &v) == 0) {
+ if (virAsprintf(&perms->owner, "%ld", v) == -1) {
+ ret = -ENOMEM;
+ goto error;
+ }
+ } else {
+ char *name;
+
+ name = virXPathString(conn, "string(./owner)", ctxt);
+ if (!name) {
+ virStorageReportError(conn, VIR_ERR_XML_ERROR,
+ "%s", _("malformed owner element"));
+ goto error;
+ }
+
+ perms->owner = name;
+ }
}
if (virXPathNode(conn, "./group", ctxt) == NULL) {
- perms->gid = getgid();
- } else {
- if (virXPathLong(conn, "number(./group)", ctxt, &v) < 0) {
- virStorageReportError(conn, VIR_ERR_XML_ERROR,
- "%s", _("malformed group element"));
+ if (virAsprintf(&perms->owner, "%d", getgid()) == -1) {
+ ret = -ENOMEM;
goto error;
}
- perms->gid = (int)v;
+ } else {
+ if (virXPathLong(conn, "number(./group)", ctxt, &v) == 0) {
+ if (virAsprintf(&perms->group, "%ld", v) == -1) {
+ ret = -ENOMEM;
+ goto error;
+ }
+ } else {
+ char *name;
+
+ name = virXPathString(conn, "string(./group)", ctxt);
+ if (!name) {
+ virStorageReportError(conn, VIR_ERR_XML_ERROR,
+ "%s", _("malformed group element"));
+ goto error;
+ }
+
+ perms->group = name;
+ }
}
/* NB, we're ignoring missing labels here - they'll simply inherit */
@@ -815,10 +848,12 @@ virStoragePoolDefFormat(virConnectPtr conn,
virBufferAddLit(&buf," <permissions>¥n");
virBufferVSprintf(&buf," <mode>0%o</mode>¥n",
def->target.perms.mode);
- virBufferVSprintf(&buf," <owner>%d</owner>¥n",
- def->target.perms.uid);
- virBufferVSprintf(&buf," <group>%d</group>¥n",
- def->target.perms.gid);
+ if (def->target.perms.owner)
+ virBufferVSprintf(&buf," <owner>%s</owner>¥n",
+ def->target.perms.owner);
+ if (def->target.perms.group)
+ virBufferVSprintf(&buf," <group>%s</group>¥n",
+ def->target.perms.group);
if (def->target.perms.label)
virBufferVSprintf(&buf," <label>%s</label>¥n",
@@ -1111,10 +1146,12 @@ virStorageVolTargetDefFormat(virConnectPtr conn,
virBufferAddLit(buf," <permissions>¥n");
virBufferVSprintf(buf," <mode>0%o</mode>¥n",
def->perms.mode);
- virBufferVSprintf(buf," <owner>%d</owner>¥n",
- def->perms.uid);
- virBufferVSprintf(buf," <group>%d</group>¥n",
- def->perms.gid);
+ if (def->perms.owner)
+ virBufferVSprintf(buf," <owner>%s</owner>¥n",
+ def->perms.owner);
+ if (def->perms.group)
+ virBufferVSprintf(buf," <group>%s</group>¥n",
+ def->perms.group);
if (def->perms.label)
diff --git a/src/storage_conf.h b/src/storage_conf.h
index 4e35ccb..212e58c 100644
--- a/src/storage_conf.h
+++ b/src/storage_conf.h
@@ -36,8 +36,8 @@ typedef struct _virStoragePerms virStoragePerms;
typedef virStoragePerms *virStoragePermsPtr;
struct _virStoragePerms {
int mode;
- int uid;
- int gid;
+ char *owner;
+ char *group;
char *label;
};
--
1.6.0.6
15 years, 7 months
[libvirt] [PATCH][take2][0/2] storage: allow alphabetical names in owner/group of permissions
by Ryota Ozaki
Hi,
This patch set allows alphabetical names in owner/group of permissions
in storage XMLs.
Change from the initial patch:
- store owner/group as strings
- As a result, dumpxml of StoragePool could return XML as it is
specified
Note that in the case of StorageVolume, dumpxml always returns
numeric owner/group, i.e., uid and gid, because current libvirt
does not store parameters of a volume into an external file but
collect info of the volume from the present filesystem using
fstat().
This behavior may lose original parameters even in the case of
uid/gid specified. I'm not sure why only StorageVolume does not
create a XML file. Anyone knows?
I should say here I don't intend to replace using numeric uid/gid
with using alphabetical names. This patch intends just to bring
ease of use and identifying what is specified for users (may not
for end-users though). And I don't still have the answer for
the question 'numbers vs. names, which is better?'.
Thanks,
ozaki-r
15 years, 7 months
[libvirt] [PATCH 4/4] VirtualBox support
by Pritesh Kothari
Hi All,
I have attached a patch which when applied on the HEAD as of today would allow
virtualbox support in libvirt. It takes cares of all the stuff mentioned on
the list earlier. Still if I have missed anything, please do tell me.
The patches are organized as below:
Patch 0/4: contains sample xml file
Patch 1/4: contains diff of files already in libvirt.
Patch 2/4: contains new files needed for VirtualBox support.
Patch 3/4: contains support for host only and internal network.
Patch 4/4: contains support for rdp in libvirt as mentioned by danpb (also had
sent it separately earlier)
Regards,
Pritesh
15 years, 7 months