Hi, I want to manage a 32 bit i686 guest on an x86_64 host with kvm and libvirt. KVM is perfectly capable of doing this (look e.g. at http://kvm.qumranet.com/kvmwiki/Guest_Support_Status) but libvirt did not allow it. So I created the attached patch to allow it and make it easy to extend the capabilities of kvm and kqemu later on. I did not add anything I'm not sure about, so I did not at 64bit guest on 32bit host (though the page linked above seems to indicate that it works) and did not change the capabilities of kqemu at all (because I don't have any experience with it and never used it). Please consider merging. Kind regards, Gerd -- Address (better: trap) for people I really don't want to get mail from: james@xxxxxxxxxxxxxxxxx
diff -r -u libvirt-0.4.2.orig/src/qemu_conf.c libvirt-0.4.2/src/qemu_conf.c --- libvirt-0.4.2.orig/src/qemu_conf.c 2008-05-29 21:25:01.000000000 +0200 +++ libvirt-0.4.2/src/qemu_conf.c 2008-06-03 01:01:19.000000000 +0200 @@ -293,6 +293,11 @@ int nflags; }; +struct hypervisor_capabilities { + const char *hostarch; + const char *guestarch; +}; + /* Feature flags for the architecture info */ static const struct qemu_feature_flags const arch_info_i686_flags [] = { { "pae", 1, 0 }, @@ -329,6 +334,17 @@ "/usr/bin/xenner", arch_info_x86_64_flags, 2 }, }; +static const struct hypervisor_capabilities const kvm_capa[] = { + { "i686", "i686" }, + { "x86_64", "i686" }, + { "x86_64", "x86_64" }, +}; + +static const struct hypervisor_capabilities const kqemu_capa[] = { + { "i686", "i686" }, + { "x86_64", "x86_64" }, +}; + static int qemudCapsInitGuest(virCapsPtr caps, const char *hostmachine, @@ -358,25 +374,33 @@ NULL) == NULL) return -1; - /* If guest & host match, then we can accelerate */ - if (STREQ(info->arch, hostmachine)) { - if (access("/dev/kqemu", F_OK) == 0 && - virCapabilitiesAddGuestDomain(guest, - "kqemu", - NULL, - NULL, - 0, - NULL) == NULL) - return -1; + /* If guest / host combo is listed as supported, we can accelerate */ + for (i = 0; i < sizeof(kqemu_capa)/sizeof(kqemu_capa[0]); i++) { + if (STREQ(hostmachine, kqemu_capa[i].hostarch) && + STREQ(info->arch, kqemu_capa[i].guestarch)) { + if (access("/dev/kqemu", F_OK) == 0 && + virCapabilitiesAddGuestDomain(guest, + "kqemu", + NULL, + NULL, + 0, + NULL) == NULL) + return -1; + } + } - if (access("/dev/kvm", F_OK) == 0 && - virCapabilitiesAddGuestDomain(guest, - "kvm", - "/usr/bin/qemu-kvm", - NULL, - 0, - NULL) == NULL) - return -1; + for (i = 0; i < sizeof(kvm_capa)/sizeof(kvm_capa[0]); i++) { + if (STREQ(hostmachine, kvm_capa[i].hostarch) && + STREQ(info->arch, kvm_capa[i].guestarch)) { + if (access("/dev/kvm", F_OK) == 0 && + virCapabilitiesAddGuestDomain(guest, + "kvm", + "/usr/bin/qemu-kvm", + NULL, + 0, + NULL) == NULL) + return -1; + } } } else { if (virCapabilitiesAddGuestDomain(guest, Only in libvirt-0.4.2/src: qemu_conf.c~
-- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list