diff options
author | Doug Goldstein <cardoe@gentoo.org> | 2009-05-27 22:34:30 +0000 |
---|---|---|
committer | Doug Goldstein <cardoe@gentoo.org> | 2009-05-27 22:34:30 +0000 |
commit | 044917a8b5841eeb23054a6744d7cc5458a32f4e (patch) | |
tree | 6695dd05db155e9a01bf1ff94f631cabbcd5bcb9 /app-emulation | |
parent | After more than an year.. some kind of update. (diff) | |
download | gentoo-2-044917a8b5841eeb23054a6744d7cc5458a32f4e.tar.gz gentoo-2-044917a8b5841eeb23054a6744d7cc5458a32f4e.tar.bz2 gentoo-2-044917a8b5841eeb23054a6744d7cc5458a32f4e.zip |
Wrote a patch to support kvm-img and qemu-img. Also made the checks for either happen at run-time instead of build-time which will improve support for people. Submitted upstream at https://bugzilla.redhat.com/show_bug.cgi?id=502956 Additional changes include adding preliminary virtualbox support. Other misc ebuild clean ups
(Portage version: 2.1.6.13/cvs/Linux x86_64)
Diffstat (limited to 'app-emulation')
-rw-r--r-- | app-emulation/libvirt/ChangeLog | 12 | ||||
-rw-r--r-- | app-emulation/libvirt/files/libvirt-0.6.3-kvm-img.patch | 270 | ||||
-rw-r--r-- | app-emulation/libvirt/libvirt-0.6.3-r1.ebuild | 108 | ||||
-rw-r--r-- | app-emulation/libvirt/metadata.xml | 2 |
4 files changed, 391 insertions, 1 deletions
diff --git a/app-emulation/libvirt/ChangeLog b/app-emulation/libvirt/ChangeLog index e134c319a7b2..dea6cd797ddf 100644 --- a/app-emulation/libvirt/ChangeLog +++ b/app-emulation/libvirt/ChangeLog @@ -1,6 +1,16 @@ # ChangeLog for app-emulation/libvirt # Copyright 1999-2009 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/app-emulation/libvirt/ChangeLog,v 1.23 2009/05/21 14:43:36 dev-zero Exp $ +# $Header: /var/cvsroot/gentoo-x86/app-emulation/libvirt/ChangeLog,v 1.24 2009/05/27 22:34:30 cardoe Exp $ + +*libvirt-0.6.3-r1 (27 May 2009) + + 27 May 2009; Doug Goldstein <cardoe@gentoo.org> +libvirt-0.6.3-r1.ebuild, + +files/libvirt-0.6.3-kvm-img.patch: + Wrote a patch to support kvm-img and qemu-img. Also made the checks for + either happen at run-time instead of build-time which will improve support + for people. Submitted upstream at + https://bugzilla.redhat.com/show_bug.cgi?id=502956 Additional changes + include adding preliminary virtualbox support. Other misc ebuild clean ups *libvirt-0.6.3 (21 May 2009) diff --git a/app-emulation/libvirt/files/libvirt-0.6.3-kvm-img.patch b/app-emulation/libvirt/files/libvirt-0.6.3-kvm-img.patch new file mode 100644 index 000000000000..8d0ed091cb82 --- /dev/null +++ b/app-emulation/libvirt/files/libvirt-0.6.3-kvm-img.patch @@ -0,0 +1,270 @@ +diff -Nur libvirt-0.6.3/configure.in libvirt-0.6.3-kvm-img/configure.in +--- libvirt-0.6.3/configure.in 2009-04-24 08:14:00.000000000 -0500 ++++ libvirt-0.6.3-kvm-img/configure.in 2009-05-27 16:49:07.000000000 -0500 +@@ -847,21 +847,6 @@ + [Location or name of the showmount program]) + fi + +-AC_PATH_PROG([QEMU_IMG], [qemu-img], [], [$PATH:/sbin:/usr/sbin:/bin:/usr/bin]) +-if test -n "$QEMU_IMG" ; then +- AC_DEFINE_UNQUOTED([HAVE_QEMU_IMG], 1, [whether qemu-img is available for non-raw files]) +- AC_DEFINE_UNQUOTED([QEMU_IMG],["$QEMU_IMG"], +- [Location or name of the qemu-img program]) +-fi +- +-AC_PATH_PROG([QCOW_CREATE], [qcow-create], [], [$PATH:/sbin:/usr/sbin:/bin:/usr/bin]) +-if test -n "$QCOW_CREATE" ; then +- AC_DEFINE_UNQUOTED([HAVE_QCOW_CREATE], 1, [whether qcow-create is available for non-raw files]) +- AC_DEFINE_UNQUOTED([QCOW_CREATE],["$QCOW_CREATE"], +- [Location or name of the qcow-create program]) +-fi +- +- + if test "$with_storage_lvm" = "yes" -o "$with_storage_lvm" = "check"; then + AC_PATH_PROG([PVCREATE], [pvcreate], [], [$PATH:/sbin:/usr/sbin]) + AC_PATH_PROG([VGCREATE], [vgcreate], [], [$PATH:/sbin:/usr/sbin]) +diff -Nur libvirt-0.6.3/src/libvirt_private.syms libvirt-0.6.3-kvm-img/src/libvirt_private.syms +--- libvirt-0.6.3/src/libvirt_private.syms 2009-04-24 07:51:46.000000000 -0500 ++++ libvirt-0.6.3-kvm-img/src/libvirt_private.syms 2009-05-27 17:15:48.000000000 -0500 +@@ -327,6 +327,7 @@ + virGetHostname; + virParseMacAddr; + virFileDeletePid; ++virFindFileInPath; + virFileExists; + virFileHasSuffix; + virFileLinkPointsTo; +diff -Nur libvirt-0.6.3/src/storage_backend_fs.c libvirt-0.6.3-kvm-img/src/storage_backend_fs.c +--- libvirt-0.6.3/src/storage_backend_fs.c 2009-04-17 14:07:48.000000000 -0500 ++++ libvirt-0.6.3-kvm-img/src/storage_backend_fs.c 2009-05-27 17:13:27.000000000 -0500 +@@ -1013,7 +1013,7 @@ + + /** + * Allocate a new file as a volume. This is either done directly +- * for raw/sparse files, or by calling qemu-img/qcow-create for ++ * for raw/sparse files, or by calling kvm-img/qemu-img/qcow-create for + * special kinds of files + */ + static int +@@ -1021,6 +1021,7 @@ + virStorageVolDefPtr vol) + { + int fd; ++ char *kvmimg = NULL, *qemuimg = NULL, *qcowcreate = NULL; + + if (vol->target.format == VIR_STORAGE_VOL_FILE_RAW) { + if ((fd = open(vol->target.path, O_RDWR | O_CREAT | O_EXCL, +@@ -1095,61 +1096,94 @@ + vol->target.path); + return -1; + } +- } else { +-#if HAVE_QEMU_IMG ++ } else if (((kvmimg = virFindFileInPath("kvm-img")) != NULL) || ++ ((qemuimg = virFindFileInPath("qemu-img")) != NULL)) { + const char *type = virStorageVolFormatFileSystemTypeToString(vol->target.format); + const char *backingType = vol->backingStore.path ? + virStorageVolFormatFileSystemTypeToString(vol->backingStore.format) : NULL; + char size[100]; +- const char **imgargv; +- const char *imgargvnormal[] = { +- QEMU_IMG, "create", "-f", type, vol->target.path, size, NULL, +- }; +- /* XXX including "backingType" here too, once QEMU accepts +- * the patches to specify it. It'll probably be -F backingType */ +- const char *imgargvbacking[] = { +- QEMU_IMG, "create", "-f", type, "-b", vol->backingStore.path, vol->target.path, size, NULL, +- }; ++ char *createtool; ++ const char *imgargv[11]; ++ int argvoffset; ++ ++ if (kvmimg != NULL) ++ imgargv[0] = kvmimg; ++ else if (qemuimg != NULL) ++ imgargv[0] = qemuimg; ++ else { ++ virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, ++ _("Can not find qemu-img or kvm-img")); ++ return -1; ++ } ++ ++ /* these values are always the same no matter the command */ ++ imgargv[1] = "create"; ++ imgargv[2] = "-f"; ++ imgargv[3] = type; ++ argvoffset = 4; + + if (type == NULL) { + virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, + _("unknown storage vol type %d"), + vol->target.format); ++ free(kvmimg); ++ free(qemuimg); + return -1; + } +- if (vol->backingStore.path == NULL) { +- imgargv = imgargvnormal; +- } else { ++ ++ if (vol->backingStore.path != NULL) { + if (backingType == NULL) { + virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, + _("unknown storage vol backing store type %d"), + vol->backingStore.format); ++ free(kvmimg); ++ free(qemuimg); + return -1; + } ++ ++ /* XXX including "backingType" here too, once QEMU accepts ++ * the patches to specify it. It'll probably be -F backingType */ ++ if (kvmimg != NULL) { ++ imgargv[argvoffset++] = "-F"; ++ imgargv[argvoffset++] = backingType; ++ } ++ + if (access(vol->backingStore.path, R_OK) != 0) { + virReportSystemError(conn, errno, + _("inaccessible backing store volume %s"), + vol->backingStore.path); ++ free(kvmimg); ++ free(qemuimg); + return -1; + } + +- imgargv = imgargvbacking; ++ imgargv[argvoffset++] = "-b"; ++ imgargv[argvoffset++] = vol->backingStore.path; + } + ++ imgargv[argvoffset++] = vol->target.path; ++ imgargv[argvoffset++] = size; ++ imgargv[argvoffset] = NULL; ++ + /* Size in KB */ + snprintf(size, sizeof(size), "%llu", vol->capacity/1024); + + if (virRun(conn, imgargv, NULL) < 0) { ++ free(kvmimg); ++ free(qemuimg); + return -1; + } + ++ free(kvmimg); ++ free(qemuimg); ++ + if ((fd = open(vol->target.path, O_RDONLY)) < 0) { + virReportSystemError(conn, errno, + _("cannot read path '%s'"), + vol->target.path); + return -1; + } +-#elif HAVE_QCOW_CREATE ++ } else if ((qcowcreate = virFindFileInPath("qcow-create")) != NULL) { + /* + * Xen removed the fully-functional qemu-img, and replaced it + * with a partially functional qcow-create. Go figure ??!? +@@ -1161,39 +1195,44 @@ + virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, + _("unsupported storage vol type %d"), + vol->target.format); ++ free(qcowcreate); + return -1; + } + if (vol->backingStore.path != NULL) { + virStorageReportError(conn, VIR_ERR_NO_SUPPORT, + _("copy-on-write image not supported with " + "qcow-create")); ++ free(qcowcreate); + return -1; + } + + /* Size in MB - yes different units to qemu-img :-( */ + snprintf(size, sizeof(size), "%llu", vol->capacity/1024/1024); + +- imgargv[0] = QCOW_CREATE; ++ imgargv[0] = qcowcreate; + imgargv[1] = size; + imgargv[2] = vol->target.path; + imgargv[3] = NULL; + + if (virRun(conn, imgargv, NULL) < 0) { ++ free(qcowcreate); + return -1; + } + ++ free(qcowcreate); ++ + if ((fd = open(vol->target.path, O_RDONLY)) < 0) { + virReportSystemError(conn, errno, + _("cannot read path '%s'"), + vol->target.path); + return -1; + } +-#else ++ } else { + virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, + "%s", _("creation of non-raw images " +- "is not supported without qemu-img")); ++ "is not supported without kvm-img or " ++ "qemu-img or qcow-create")); + return -1; +-#endif + } + + /* We can only chown/grp if root */ +diff -Nur libvirt-0.6.3/src/util.c libvirt-0.6.3-kvm-img/src/util.c +--- libvirt-0.6.3/src/util.c 2009-04-24 04:46:45.000000000 -0500 ++++ libvirt-0.6.3-kvm-img/src/util.c 2009-05-27 16:54:23.000000000 -0500 +@@ -1002,6 +1002,38 @@ + return(0); + } + ++/* ++ * Find a file in the PATH. You must free ++ * the result ++ */ ++char *virFindFileInPath(const char *find) ++{ ++ char pathenv[PATH_MAX]; ++ char *pathseg; ++ char *fullpath; ++ ++ /* copy PATH env so we can tweak it */ ++ strncpy(pathenv, getenv("PATH"), PATH_MAX); ++ pathenv[PATH_MAX - 1] = '\0'; ++ ++ /* buffer for our file path */ ++ fullpath = malloc(PATH_MAX); ++ if (fullpath == NULL) ++ return NULL; ++ ++ /* for each path segment, append the file name to search for ++ * and test for it. return it if successful */ ++ while ((pathseg = strsep(&pathenv, ":")) != NULL) { ++ snprintf(fullpath, PATH_MAX, "%s/%s", pathseg, find); ++ if (virFileExists(fullpath)) ++ return fullpath; ++ } ++ ++ free(fullpath); ++ ++ return NULL; ++} ++ + int virFileMakePath(const char *path) + { + struct stat st; +diff -Nur libvirt-0.6.3/src/util.h libvirt-0.6.3-kvm-img/src/util.h +--- libvirt-0.6.3/src/util.h 2009-04-24 04:46:45.000000000 -0500 ++++ libvirt-0.6.3-kvm-img/src/util.h 2009-05-27 16:15:26.000000000 -0500 +@@ -92,6 +92,8 @@ + + int virFileExists(const char *path); + ++char *virFindFileInPath(const char *find); ++ + int virFileMakePath(const char *path); + + int virFileBuildPath(const char *dir, diff --git a/app-emulation/libvirt/libvirt-0.6.3-r1.ebuild b/app-emulation/libvirt/libvirt-0.6.3-r1.ebuild new file mode 100644 index 000000000000..5cda769a6804 --- /dev/null +++ b/app-emulation/libvirt/libvirt-0.6.3-r1.ebuild @@ -0,0 +1,108 @@ +# Copyright 1999-2009 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/app-emulation/libvirt/libvirt-0.6.3-r1.ebuild,v 1.1 2009/05/27 22:34:30 cardoe Exp $ + +EAPI="2" + +inherit eutils autotools confutils + +DESCRIPTION="C toolkit to manipulate virtual machines" +HOMEPAGE="http://www.libvirt.org/" +SRC_URI="http://libvirt.org/sources/${P}.tar.gz" +LICENSE="LGPL-2.1" +SLOT="0" +KEYWORDS="~amd64 ~x86" +IUSE="avahi iscsi hal kvm lvm +lxc +network nls openvz policykit parted qemu \ + sasl selinux uml virtualbox xen" +# devicekit isn't in portage + +RDEPEND="sys-libs/readline + sys-libs/ncurses + >=dev-libs/libxml2-2.5 + >=net-libs/gnutls-1.0.25 + dev-lang/python + sys-fs/sysfsutils + net-analyzer/netcat + avahi? ( >=net-dns/avahi-0.6 ) + iscsi? ( sys-block/open-iscsi ) + kvm? ( app-emulation/kvm ) + lvm? ( sys-fs/lvm2 ) + network? ( net-misc/bridge-utils net-dns/dnsmasq net-firewall/iptables ) + openvz? ( sys-kernel/openvz-sources ) + parted? ( >=sys-apps/parted-1.8 ) + policykit? ( >=sys-auth/policykit-0.6 ) + qemu? ( app-emulation/qemu ) + sasl? ( dev-libs/cyrus-sasl ) + selinux? ( sys-libs/libselinux ) + virtualbox? ( app-emulation/virtualbox-bin ) + xen? ( app-emulation/xen-tools app-emulation/xen )" +DEPEND="${RDEPEND} + dev-util/pkgconfig" + +src_prepare() { + epatch \ + "${FILESDIR}/${P}-kvm-85-argv-detection.patch" \ + "${FILESDIR}/${P}-kvm-img.patch" + eautoreconf + + # "${FILESDIR}/${PN}-0.6.2-storage-fix.patch" \ +} + +pkg_setup() { + confutils_require_any lxc kvm openvz qemu uml virtualbox xen +} + +src_configure() { + local my_conf="" + if use qemu || use kvm ; then + my_conf="--with-qemu" + else + my_conf="--without-qemu" + fi + + econf \ + $(use_with iscsi storage-iscsi) \ + $(use_with lvm storage-lvm) \ + $(use_with parted storage-disk) \ + $(use_with lxc) \ + $(use_with openvz) \ + $(use_with uml) \ + $(use_with virtualbox vbox) \ + $(use_with xen) \ + $(use_with xen xen-inotify) \ + $(use_with avahi) \ + $(use_with hal) \ + $(use_with sasl) \ + $(use_with network) \ + $(use_with policykit polkit) \ + $(use_with selinux) \ + $(use_enable nls) \ + ${my_conf} \ + --without-devkit \ + --with-remote \ + --disable-iptables-lokkit \ + --localstatedir=/var \ + --with-remote-pid-file=/var/run/libvirtd.pid +} + +src_install() { + emake DESTDIR="${D}" install || die "emake instal lfailed" + mv "${D}"/usr/share/doc/{${PN}-python*,${P}/python} + + newinitd "${FILESDIR}/libvirtd.init" libvirtd + newconfd "${FILESDIR}/libvirtd.confd" libvirtd + + keepdir /var/lib/libvirt/images +} + +pkg_postinst() { + elog "To allow normal users to connect to libvirtd you must change the" + elog " unix sock group and/or perms in /etc/libvirt/libvirtd.conf" + elog + ewarn "If you have a DNS server setup on your machine, you will have" + ewarn "to configure /etc/dnsmasq.conf to enable the following settings: " + ewarn " bind-interfaces" + ewarn " interface or except-interface" + elog + ewarn "Otherwise you might have issues with your existing DNS server." +} diff --git a/app-emulation/libvirt/metadata.xml b/app-emulation/libvirt/metadata.xml index e516b1b3e8a2..64cb2c0e11f1 100644 --- a/app-emulation/libvirt/metadata.xml +++ b/app-emulation/libvirt/metadata.xml @@ -29,5 +29,7 @@ <flag name='xen'>Add support for <pkg>app-emulation/xen</pkg> based virtual machines</flag> <flag name='network'>Enable networking support for guests</flag> + <flag name='virtualbox'>Adds support for VirtualBox based virtual + machines</flag> </use> </pkgmetadata> |