[PATCH 3/3] qemu: add PCI root to MIPS Malta machine
MIPS Malta (and no other supported MIPS machine) has a PCI bus. Signed-off-by: Lubomir Rintel --- src/qemu/qemu_domain.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0bae9b9202..b7aad65048 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3703,6 +3703,14 @@ qemuDomainDefAddDefaultDevices(virQEMUDriver *driver, addPCIRoot = true; break; +case VIR_ARCH_MIPS: +case VIR_ARCH_MIPSEL: +case VIR_ARCH_MIPS64: +case VIR_ARCH_MIPS64EL: +if (qemuDomainIsMipsMalta(def)) +addPCIRoot = true; +break; + case VIR_ARCH_ARMV7B: case VIR_ARCH_CRIS: case VIR_ARCH_ITANIUM: @@ -3710,10 +3718,6 @@ qemuDomainDefAddDefaultDevices(virQEMUDriver *driver, case VIR_ARCH_M68K: case VIR_ARCH_MICROBLAZE: case VIR_ARCH_MICROBLAZEEL: -case VIR_ARCH_MIPS: -case VIR_ARCH_MIPSEL: -case VIR_ARCH_MIPS64: -case VIR_ARCH_MIPS64EL: case VIR_ARCH_OR32: case VIR_ARCH_PARISC: case VIR_ARCH_PARISC64: -- 2.34.1
[PATCH 1/3] util: add ARCH_IS_MIPS helper macro
Identifies all of various MIPS sub-architectures: 32-bit or 64-bit, little-endian or big-endian. Signed-off-by: Lubomir Rintel --- src/util/virarch.h | 5 + 1 file changed, 5 insertions(+) diff --git a/src/util/virarch.h b/src/util/virarch.h index 528f84f8a5..81b1b27a57 100644 --- a/src/util/virarch.h +++ b/src/util/virarch.h @@ -95,6 +95,11 @@ typedef enum { #define ARCH_IS_S390(arch) ((arch) == VIR_ARCH_S390 ||\ (arch) == VIR_ARCH_S390X) +#define ARCH_IS_MIPS(arch) ((arch) == VIR_ARCH_MIPS ||\ +(arch) == VIR_ARCH_MIPSEL ||\ +(arch) == VIR_ARCH_MIPS64 ||\ +(arch) == VIR_ARCH_MIPS64EL) + #define ARCH_IS_MIPS64(arch) ((arch) == VIR_ARCH_MIPS64 ||\ (arch) == VIR_ARCH_MIPS64EL) -- 2.34.1
[PATCH 2/3] qemu: add qemuDomainIsMipsMalta()
This identifies various MIPS Malta machines, be it 32-bit or 64-bit, little-endian or big-endian. Signed-off-by: Lubomir Rintel --- src/qemu/qemu_domain.c | 21 + src/qemu/qemu_domain.h | 1 + 2 files changed, 22 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6b915d7535..0bae9b9202 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8647,6 +8647,20 @@ qemuDomainMachineIsPSeries(const char *machine, } +static bool +qemuDomainMachineIsMipsMalta(const char *machine, + const virArch arch) +{ +if (!ARCH_IS_MIPS(arch)) +return false; + +if (STREQ(machine, "malta")) +return true; + +return false; +} + + /* You should normally avoid this function and use * qemuDomainHasBuiltinIDE() instead. */ bool @@ -8719,6 +8733,13 @@ qemuDomainIsPSeries(const virDomainDef *def) } +bool +qemuDomainIsMipsMalta(const virDomainDef *def) +{ +return qemuDomainMachineIsMipsMalta(def->os.machine, def->os.arch); +} + + bool qemuDomainHasPCIRoot(const virDomainDef *def) { diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index e5046367e3..78474b3f73 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -770,6 +770,7 @@ bool qemuDomainIsS390CCW(const virDomainDef *def); bool qemuDomainIsARMVirt(const virDomainDef *def); bool qemuDomainIsRISCVVirt(const virDomainDef *def); bool qemuDomainIsPSeries(const virDomainDef *def); +bool qemuDomainIsMipsMalta(const virDomainDef *def); bool qemuDomainHasPCIRoot(const virDomainDef *def); bool qemuDomainHasPCIeRoot(const virDomainDef *def); bool qemuDomainHasBuiltinIDE(const virDomainDef *def); -- 2.34.1
[PATCH 0/3] Unbreak MIPS Malta
My day started like this: # virt-install --connect qemu:///system --arch mips --machine malta --memory 256 --disk none --import Using default --name vm-mips Starting install... ERRORXML error: No PCI buses available Needless to say, it ended up completely ruined. Chained to this message are the patches I've created in an attempt to remedy the highly unfortunate situation, with hope that they'll be treated with warmth, understanding and perhaps even applied to the libvirt tree. Yours, Lubo
[libvirt] [PATCH] lxc: Fix reboot via initctl
virInitctlSetRunLevel() returns 0 only if ended up doing nothing, 1 if it actually succeeded. Let's check for the error condition. Without this, a successful reboot would be treated as a failure and the LXC driver will proceed sending a TERM signal instead, effectively cancelling the shutdown. Signed-off-by: Lubomir Rintel --- src/lxc/lxc_domain.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c index 51a9fd36eb..1dc2d0d4cf 100644 --- a/src/lxc/lxc_domain.c +++ b/src/lxc/lxc_domain.c @@ -457,7 +457,9 @@ lxcDomainInitctlCallback(pid_t pid ATTRIBUTE_UNUSED, data->st[i].st_ino == cont_sb.st_ino) continue; -return virInitctlSetRunLevel(fifo, data->runlevel); +if (virInitctlSetRunLevel(fifo, data->runlevel) == -1) +return -1; +return 0; } /* If no usable fifo was found then declare success. Caller -- 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 6/9] qemu: add qemuDomainAssignVirtioMMIOAddresses()
On Thu, 2018-08-23 at 17:43 +0200, Andrea Bolognani wrote: > On Wed, 2018-08-22 at 11:15 +0200, Lubomir Rintel wrote: > > A short not explaining why you need to do this, along the lines of > > We're going to need to assign virtio-mmio addresses to non-ARM > guests soon, so let's create a generic wrapper that calls to > the architecture-specific implementation. > > sure would be nice... Are you okay with me adding it to the commit > message before pushing? Yes, that would be fine. > > Either way the code is fine, so > > Reviewed-by: Andrea Bolognani Thanks, Lubo -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 0/9] RISC-V Guest Support
Hi. Third iteration of RISC-V guest support. I believe I addressed all points of Andrea's review. Tested with: images from [1]: virt-install \ --import --name riscv64 \ --arch riscv64 --machine virt \ --memory 2048 \ --rng /dev/urandom \ --disk /var/lib/libvirt/images/stage4-disk.img,bus=virtio \ --boot kernel=/var/lib/libvirt/images/bbl,kernel_args="console=ttyS0 ro root=/dev/vda" [1] https://fedorapeople.org/groups/risc-v/disk-images/ Note that the large test suite changes that touch the '*.replies' files seem to upset the mail server, thus you're unlikely to receive them from the list. You can get them straight from my repository instead: git pull https://github.com/lkundrak/libvirt.git lr/riscv-v3 Changes since v2: * Regenerated cap test data with QEMU 3.0.0 * Squashed the tests together * Folded "docs/schemas: add RISC-V architectures" into "util: add RISC-V architectures" * Streamlined the Virtio MMIO address assignment * Added qemuDomainIsRISCVVirt() and qemuDomainMachineIsRISCVVirt() * Cosmetic changes to "util: add RISC-V architectures" * New commits: qemu: add qemuDomainAssignVirtioMMIOAddresses() qemu: add qemuDomainIsRISCVVirt() and qemuDomainMachineIsRISCVVirt() qemu: RISC-V machines have no PCI news: Add a mention of RISC-V guest support * Dropped: qemu: no USB by default on RISC-V machines (not sure why I thought this was needed) Lubomir Rintel (9): qemu: rename qemuDomainMachineIsVirt() qemu: rename qemuDomainArmVirt() util: add RISC-V architectures qemu: RISC-V machines have no PCI qemu: add qemuDomainIsRISCVVirt() and qemuDomainMachineIsRISCVVirt() qemu: add qemuDomainAssignVirtioMMIOAddresses() qemu: assign addresses to virtio devices on RISC-V tests: Add RISC-V architectures news: Add a mention of RISC-V guest support docs/news.xml | 8 + docs/schemas/basictypes.rng | 2 + src/qemu/qemu_capabilities.c | 6 +- src/qemu/qemu_command.c | 4 +- src/qemu/qemu_domain.c|46 +- src/qemu/qemu_domain.h| 9 +- src/qemu/qemu_domain_address.c|34 +- src/util/virarch.c| 5 +- src/util/virarch.h| 8 +- tests/capabilityschemadata/caps-qemu-kvm.xml |36 + .../caps_3.0.0.riscv32.replies| 14819 .../caps_3.0.0.riscv32.xml| 118 + .../caps_3.0.0.riscv64.replies| 14819 .../caps_3.0.0.riscv64.xml| 118 + tests/qemucapabilitiestest.c | 2 + tests/qemuxml2argvdata/riscv64-virt.args |30 + tests/qemuxml2argvdata/riscv64-virt.xml |32 + tests/qemuxml2argvtest.c | 3 + .../riscv64-virt.xml |42 + tests/qemuxml2xmloutdata/riscv64-virt.xml |36 + tests/qemuxml2xmltest.c | 2 + tests/testutilsqemu.c |72 + tests/vircapstest.c | 6 + 23 files changed, 30232 insertions(+), 25 deletions(-) create mode 100644 tests/qemucapabilitiesdata/caps_3.0.0.riscv32.replies create mode 100644 tests/qemucapabilitiesdata/caps_3.0.0.riscv32.xml create mode 100644 tests/qemucapabilitiesdata/caps_3.0.0.riscv64.replies create mode 100644 tests/qemucapabilitiesdata/caps_3.0.0.riscv64.xml create mode 100644 tests/qemuxml2argvdata/riscv64-virt.args create mode 100644 tests/qemuxml2argvdata/riscv64-virt.xml create mode 100644 tests/qemuxml2startupxmloutdata/riscv64-virt.xml create mode 100644 tests/qemuxml2xmloutdata/riscv64-virt.xml -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 4/9] qemu: RISC-V machines have no PCI
Signed-off-by: Lubomir Rintel --- src/qemu/qemu_domain_address.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 6c540a8094..551883e989 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -2157,7 +2157,9 @@ static bool qemuDomainSupportsPCI(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) { -if ((def->os.arch != VIR_ARCH_ARMV7L) && (def->os.arch != VIR_ARCH_AARCH64)) +if ((def->os.arch != VIR_ARCH_ARMV7L) && +(def->os.arch != VIR_ARCH_AARCH64) && +!ARCH_IS_RISCV(def->os.arch)) return true; if (STREQ(def->os.machine, "versatilepb")) -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 7/9] qemu: assign addresses to virtio devices on RISC-V
Signed-off-by: Lubomir Rintel --- src/qemu/qemu_domain_address.c | 16 1 file changed, 16 insertions(+) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 317f280f92..29a1def24c 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -485,11 +485,27 @@ qemuDomainAssignARMVirtioMMIOAddresses(virDomainDefPtr def, } +static void +qemuDomainAssignRISCVVirtioMMIOAddresses(virDomainDefPtr def, + virQEMUCapsPtr qemuCaps) +{ +if (!qemuDomainIsRISCVVirt(def)) +return; + +if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MMIO)) { +qemuDomainPrimeVirtioDeviceAddresses(def, + VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO); +} +} + + static void qemuDomainAssignVirtioMMIOAddresses(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) { qemuDomainAssignARMVirtioMMIOAddresses(def, qemuCaps); + +qemuDomainAssignRISCVVirtioMMIOAddresses(def, qemuCaps); } -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 3/9] util: add RISC-V architectures
Signed-off-by: Lubomir Rintel Reviewed-by: Andrea Bolognani --- docs/schemas/basictypes.rng | 2 ++ src/qemu/qemu_domain.c | 2 ++ src/util/virarch.c | 5 - src/util/virarch.h | 8 +++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng index 1a18cd31b1..14a3670e5c 100644 --- a/docs/schemas/basictypes.rng +++ b/docs/schemas/basictypes.rng @@ -398,6 +398,8 @@ ppc64 ppc64le ppcemb + riscv32 + riscv64 s390 s390x sh4 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index fcb37d45e6..60b4a9b412 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3249,6 +3249,8 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def, case VIR_ARCH_OR32: case VIR_ARCH_PARISC: case VIR_ARCH_PARISC64: +case VIR_ARCH_RISCV32: +case VIR_ARCH_RISCV64: case VIR_ARCH_PPCLE: case VIR_ARCH_UNICORE32: case VIR_ARCH_XTENSA: diff --git a/src/util/virarch.c b/src/util/virarch.c index be48bcfb89..3f5efde8e2 100644 --- a/src/util/virarch.c +++ b/src/util/virarch.c @@ -65,15 +65,18 @@ static const struct virArchData { { "ppc64le", 64, VIR_ARCH_LITTLE_ENDIAN }, { "ppcemb", 32, VIR_ARCH_BIG_ENDIAN }, +{ "riscv32", 32, VIR_ARCH_LITTLE_ENDIAN }, +{ "riscv64", 64, VIR_ARCH_LITTLE_ENDIAN }, { "s390", 32, VIR_ARCH_BIG_ENDIAN }, { "s390x",64, VIR_ARCH_BIG_ENDIAN }, { "sh4", 32, VIR_ARCH_LITTLE_ENDIAN }, + { "sh4eb",64, VIR_ARCH_BIG_ENDIAN }, { "sparc",32, VIR_ARCH_BIG_ENDIAN }, - { "sparc64", 64, VIR_ARCH_BIG_ENDIAN }, { "unicore32",32, VIR_ARCH_LITTLE_ENDIAN }, { "x86_64", 64, VIR_ARCH_LITTLE_ENDIAN }, + { "xtensa", 32, VIR_ARCH_LITTLE_ENDIAN }, { "xtensaeb", 32, VIR_ARCH_BIG_ENDIAN }, }; diff --git a/src/util/virarch.h b/src/util/virarch.h index af5ff83528..a52de7f52c 100644 --- a/src/util/virarch.h +++ b/src/util/virarch.h @@ -55,15 +55,18 @@ typedef enum { VIR_ARCH_PPC64LE, /* PowerPC 64 LE http://en.wikipedia.org/wiki/PowerPC */ VIR_ARCH_PPCEMB, /* PowerPC 32 BE http://en.wikipedia.org/wiki/PowerPC */ +VIR_ARCH_RISCV32, /* RISC-V 64 LE http://en.wikipedia.org/wiki/RISC-V */ +VIR_ARCH_RISCV64, /* RISC-V 32 BE http://en.wikipedia.org/wiki/RISC-V */ VIR_ARCH_S390, /* S39032 BE http://en.wikipedia.org/wiki/S390 */ VIR_ARCH_S390X,/* S39064 BE http://en.wikipedia.org/wiki/S390x */ VIR_ARCH_SH4, /* SuperH4 32 LE http://en.wikipedia.org/wiki/SuperH */ + VIR_ARCH_SH4EB,/* SuperH4 32 BE http://en.wikipedia.org/wiki/SuperH */ VIR_ARCH_SPARC,/* Sparc 32 BE http://en.wikipedia.org/wiki/Sparc */ - VIR_ARCH_SPARC64, /* Sparc 64 BE http://en.wikipedia.org/wiki/Sparc */ VIR_ARCH_UNICORE32,/* UniCore 32 LE http://en.wikipedia.org/wiki/Unicore*/ VIR_ARCH_X86_64, /* x86 64 LE http://en.wikipedia.org/wiki/X86 */ + VIR_ARCH_XTENSA, /* XTensa 32 LE http://en.wikipedia.org/wiki/Xtensa#Processor_Cores */ VIR_ARCH_XTENSAEB, /* XTensa 32 BE http://en.wikipedia.org/wiki/Xtensa#Processor_Cores */ @@ -87,6 +90,9 @@ typedef enum { (arch) == VIR_ARCH_ARMV7B ||\ (arch) == VIR_ARCH_AARCH64) +# define ARCH_IS_RISCV(arch) ((arch) == VIR_ARCH_RISCV32 ||\ + (arch) == VIR_ARCH_RISCV64) + # define ARCH_IS_S390(arch) ((arch) == VIR_ARCH_S390 ||\ (arch) == VIR_ARCH_S390X) -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 5/9] qemu: add qemuDomainIsRISCVVirt() and qemuDomainMachineIsRISCVVirt()
Signed-off-by: Lubomir Rintel --- src/qemu/qemu_domain.c | 22 ++ src/qemu/qemu_domain.h | 3 +++ 2 files changed, 25 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 60b4a9b412..b43e9b76d4 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9477,6 +9477,28 @@ qemuDomainMachineIsARMVirt(const char *machine, } +bool +qemuDomainIsRISCVVirt(const virDomainDef *def) +{ +return qemuDomainMachineIsRISCVVirt(def->os.machine, def->os.arch); +} + + +bool +qemuDomainMachineIsRISCVVirt(const char *machine, + const virArch arch) +{ +if (!ARCH_IS_RISCV(arch)) +return false; + +if (STRNEQ(machine, "virt") && +!STRPREFIX(machine, "virt-")) +return false; + +return true; +} + + bool qemuDomainIsPSeries(const virDomainDef *def) { diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 898b5b4479..be9c4b7d61 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -810,6 +810,7 @@ bool qemuDomainHasPCIeRoot(const virDomainDef *def); bool qemuDomainNeedsFDC(const virDomainDef *def); bool qemuDomainIsS390CCW(const virDomainDef *def); bool qemuDomainIsARMVirt(const virDomainDef *def); +bool qemuDomainIsRISCVVirt(const virDomainDef *def); bool qemuDomainIsPSeries(const virDomainDef *def); bool qemuDomainHasBuiltinIDE(const virDomainDef *def); @@ -819,6 +820,8 @@ bool qemuDomainMachineNeedsFDC(const char *machine); bool qemuDomainMachineIsS390CCW(const char *machine); bool qemuDomainMachineIsARMVirt(const char *machine, const virArch arch); +bool qemuDomainMachineIsRISCVVirt(const char *machine, + const virArch arch); bool qemuDomainMachineIsPSeries(const char *machine, const virArch arch); bool qemuDomainMachineHasBuiltinIDE(const char *machine); -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 1/9] qemu: rename qemuDomainMachineIsVirt()
It's ARM specific. Signed-off-by: Lubomir Rintel --- src/qemu/qemu_capabilities.c | 2 +- src/qemu/qemu_domain.c | 6 +++--- src/qemu/qemu_domain.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 9edb4ca4d4..d9b1089c59 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5335,7 +5335,7 @@ virQEMUCapsFillDomainFeatureGICCaps(virQEMUCapsPtr qemuCaps, virDomainCapsFeatureGICPtr gic = >gic; virGICVersion version; -if (!qemuDomainMachineIsVirt(domCaps->machine, domCaps->arch)) +if (!qemuDomainMachineIsARMVirt(domCaps->machine, domCaps->arch)) return 0; for (version = VIR_GIC_VERSION_LAST - 1; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index f570081e3a..ad7f4091f6 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9455,13 +9455,13 @@ qemuDomainMachineIsS390CCW(const char *machine) bool qemuDomainIsVirt(const virDomainDef *def) { -return qemuDomainMachineIsVirt(def->os.machine, def->os.arch); +return qemuDomainMachineIsARMVirt(def->os.machine, def->os.arch); } bool -qemuDomainMachineIsVirt(const char *machine, -const virArch arch) +qemuDomainMachineIsARMVirt(const char *machine, + const virArch arch) { if (arch != VIR_ARCH_ARMV7L && arch != VIR_ARCH_AARCH64) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index bff293fc0a..f883780215 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -817,8 +817,8 @@ bool qemuDomainMachineIsQ35(const char *machine); bool qemuDomainMachineIsI440FX(const char *machine); bool qemuDomainMachineNeedsFDC(const char *machine); bool qemuDomainMachineIsS390CCW(const char *machine); -bool qemuDomainMachineIsVirt(const char *machine, - const virArch arch); +bool qemuDomainMachineIsARMVirt(const char *machine, +const virArch arch); bool qemuDomainMachineIsPSeries(const char *machine, const virArch arch); bool qemuDomainMachineHasBuiltinIDE(const char *machine); -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 6/9] qemu: add qemuDomainAssignVirtioMMIOAddresses()
Signed-off-by: Lubomir Rintel --- src/qemu/qemu_domain_address.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 551883e989..317f280f92 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -485,6 +485,14 @@ qemuDomainAssignARMVirtioMMIOAddresses(virDomainDefPtr def, } +static void +qemuDomainAssignVirtioMMIOAddresses(virDomainDefPtr def, +virQEMUCapsPtr qemuCaps) +{ +qemuDomainAssignARMVirtioMMIOAddresses(def, qemuCaps); +} + + /** * qemuDomainDeviceCalculatePCIConnectFlags: * @@ -2923,7 +2931,7 @@ qemuDomainAssignAddresses(virDomainDefPtr def, if (qemuDomainAssignS390Addresses(def, qemuCaps) < 0) return -1; -qemuDomainAssignARMVirtioMMIOAddresses(def, qemuCaps); +qemuDomainAssignVirtioMMIOAddresses(def, qemuCaps); if (qemuDomainAssignPCIAddresses(def, qemuCaps, driver, obj) < 0) return -1; -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 2/9] qemu: rename qemuDomainArmVirt()
It's ARM specific. Signed-off-by: Lubomir Rintel --- src/qemu/qemu_capabilities.c | 4 ++-- src/qemu/qemu_command.c| 4 ++-- src/qemu/qemu_domain.c | 16 src/qemu/qemu_domain.h | 2 +- src/qemu/qemu_domain_address.c | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index d9b1089c59..d2f7e9efa6 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1787,10 +1787,10 @@ bool virQEMUCapsHasPCIMultiBus(virQEMUCapsPtr qemuCaps, return false; } -/* If 'virt' supports PCI, it supports multibus. +/* If ARM 'virt' supports PCI, it supports multibus. * No extra conditions here for simplicity. */ -if (qemuDomainIsVirt(def)) +if (qemuDomainIsARMVirt(def)) return true; return false; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ec46db5c36..334f14913a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2948,7 +2948,7 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd, if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB && cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT && !qemuDomainIsQ35(def) && -!qemuDomainIsVirt(def)) { +!qemuDomainIsARMVirt(def)) { /* An appropriate default USB controller model should already * have been selected in qemuDomainDeviceDefPostParse(); if @@ -2986,7 +2986,7 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd, if (usbcontroller == 0 && !qemuDomainIsQ35(def) && -!qemuDomainIsVirt(def) && +!qemuDomainIsARMVirt(def) && !ARCH_IS_S390(def->os.arch)) { /* We haven't added any USB controller yet, but we haven't been asked * not to add one either. Add a legacy USB controller, unless we're diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ad7f4091f6..fcb37d45e6 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3199,7 +3199,7 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def, case VIR_ARCH_AARCH64: addDefaultUSB = false; addDefaultMemballoon = false; -if (qemuDomainIsVirt(def)) +if (qemuDomainIsARMVirt(def)) addPCIeRoot = virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_GPEX); break; @@ -3380,7 +3380,7 @@ qemuDomainDefEnableDefaultFeatures(virDomainDefPtr def, * was not included in the domain XML, we need to choose a suitable * GIC version ourselves */ if ((def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ABSENT && - qemuDomainIsVirt(def)) || + qemuDomainIsARMVirt(def)) || (def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ON && def->gic_version == VIR_GIC_VERSION_NONE)) { virGICVersion version; @@ -3832,7 +3832,7 @@ qemuDomainDefValidateFeatures(const virDomainDef *def, case VIR_DOMAIN_FEATURE_GIC: if (def->features[i] == VIR_TRISTATE_SWITCH_ON && -!qemuDomainIsVirt(def)) { +!qemuDomainIsARMVirt(def)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("The '%s' feature is not supported for " "architecture '%s' or machine type '%s'"), @@ -4245,7 +4245,7 @@ qemuDomainChrDefValidate(const virDomainChrDef *dev, isCompatible = false; } -if (!qemuDomainIsVirt(def) && +if (!qemuDomainIsARMVirt(def) && (dev->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM || dev->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011)) { isCompatible = false; @@ -5770,7 +5770,7 @@ qemuDomainDefaultNetModel(const virDomainDef *def, if (STREQ(def->os.machine, "versatilepb")) return "smc91c111"; -if (qemuDomainIsVirt(def)) +if (qemuDomainIsARMVirt(def)) return "virtio"; /* Incomplete. vexpress (and a few others) use this, but not all @@ -6070,7 +6070,7 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr, chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA; } else if (qemuDomainIsPSeries(def)) { chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO; -} else if (qemuDomainIsVirt(def)) { +} else if (qemuDomainIsARMVirt(def)) { chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM; } else if (ARCH_IS_S390(def->os.arch)) { chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP; @@ -6264,7 +6264,7 @@ qemuDomainDeviceVideoDefPostParse(virD
[libvirt] [PATCH v3 9/9] news: Add a mention of RISC-V guest support
Signed-off-by: Lubomir Rintel --- docs/news.xml | 8 1 file changed, 8 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index c6d03f5556..2b6d08dc02 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -53,6 +53,14 @@ bandwidth by using the memorytune element in cputune. + + + qemu: Add support for RISC-V guests + + + riscv32 and riscv64 guest architectures are now supported. + + -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 06/11] qemu: assign addresses to virtio devices on RISC-V
Signed-off-by: Lubomir Rintel --- src/qemu/qemu_domain_address.c | 19 +++ 1 file changed, 19 insertions(+) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 01cfdbeadf..d3259212f5 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -502,6 +502,23 @@ qemuDomainAssignARMVirtioMMIOAddresses(virDomainDefPtr def, } +static void +qemuDomainAssignRISCVVirtioMMIOAddresses(virDomainDefPtr def, + virQEMUCapsPtr qemuCaps) +{ +if (!ARCH_IS_RISCV(def->os.arch)) +return; + +if (STRNEQ(def->os.machine, "virt")) +return; + +if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MMIO)) { +qemuDomainPrimeVirtioDeviceAddresses(def, + VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO); +} +} + + /** * qemuDomainDeviceCalculatePCIConnectFlags: * @@ -2940,6 +2957,8 @@ qemuDomainAssignAddresses(virDomainDefPtr def, qemuDomainAssignARMVirtioMMIOAddresses(def, qemuCaps); +qemuDomainAssignRISCVVirtioMMIOAddresses(def, qemuCaps); + if (qemuDomainAssignPCIAddresses(def, qemuCaps, driver, obj) < 0) return -1; -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 04/11] docs/schemas: add RISC-V architectures
Signed-off-by: Lubomir Rintel --- docs/schemas/basictypes.rng | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng index 1a18cd31b1..14a3670e5c 100644 --- a/docs/schemas/basictypes.rng +++ b/docs/schemas/basictypes.rng @@ -398,6 +398,8 @@ ppc64 ppc64le ppcemb + riscv32 + riscv64 s390 s390x sh4 -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 10/11] tests/qemuxml2argvtest: test RISC-V virt machine arguments
Signed-off-by: Lubomir Rintel --- tests/qemuxml2argvdata/riscv64-virt.args | 31 +++ tests/qemuxml2argvdata/riscv64-virt.xml | 32 +++ tests/qemuxml2argvtest.c | 3 ++ .../riscv64-virt.xml | 39 +++ 4 files changed, 105 insertions(+) create mode 100644 tests/qemuxml2argvdata/riscv64-virt.args create mode 100644 tests/qemuxml2argvdata/riscv64-virt.xml create mode 100644 tests/qemuxml2startupxmloutdata/riscv64-virt.xml diff --git a/tests/qemuxml2argvdata/riscv64-virt.args b/tests/qemuxml2argvdata/riscv64-virt.args new file mode 100644 index 00..1833242753 --- /dev/null +++ b/tests/qemuxml2argvdata/riscv64-virt.args @@ -0,0 +1,31 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-riscv64 \ +-name riscv64 \ +-S \ +-machine virt,accel=tcg,usb=off,dump-guest-core=off \ +-m 2048 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid fd65fc03-8838-4c4d-9d8d-395802488790 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-riscv64/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-boot c \ +-kernel /var/lib/libvirt/images/bbl \ +-append 'console=ttyS0 ro root=/dev/vda' \ +-usb \ +-drive file=/var/lib/libvirt/images/stage4-disk.img,format=raw,if=none,\ +id=drive-virtio-disk0 \ +-device virtio-blk-device,drive=drive-virtio-disk0,id=virtio-disk0 \ +-chardev pty,id=charserial0 \ +-serial chardev:charserial0 \ +-device virtio-balloon-device,id=balloon0 diff --git a/tests/qemuxml2argvdata/riscv64-virt.xml b/tests/qemuxml2argvdata/riscv64-virt.xml new file mode 100644 index 00..6a2d072d3c --- /dev/null +++ b/tests/qemuxml2argvdata/riscv64-virt.xml @@ -0,0 +1,32 @@ + + riscv64 + fd65fc03-8838-4c4d-9d8d-395802488790 + 2097152 + 2097152 + 1 + +hvm +/var/lib/libvirt/images/bbl +console=ttyS0 ro root=/dev/vda + + + + destroy + restart + destroy + +/usr/bin/qemu-system-riscv64 + + + + + + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index f44cac9fef..9c4cf1bb37 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2903,6 +2903,9 @@ mymain(void) QEMU_CAPS_KVM, QEMU_CAPS_SEV_GUEST); +DO_TEST("riscv64-virt", +QEMU_CAPS_DEVICE_VIRTIO_MMIO); + if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL) virFileDeleteTree(fakerootdir); diff --git a/tests/qemuxml2startupxmloutdata/riscv64-virt.xml b/tests/qemuxml2startupxmloutdata/riscv64-virt.xml new file mode 100644 index 00..e23b3ffbad --- /dev/null +++ b/tests/qemuxml2startupxmloutdata/riscv64-virt.xml @@ -0,0 +1,39 @@ + + riscv64 + fd65fc03-8838-4c4d-9d8d-395802488790 + 2097152 + 2097152 + 1 + +hvm +/var/lib/libvirt/images/bbl +console=ttyS0 ro root=/dev/vda + + + + destroy + restart + destroy + +/usr/bin/qemu-system-riscv64 + + + + + + + + + + + + + + + + + + + + + -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 02/11] qemu: rename qemuDomainArmVirt()
It's ARM specific. Signed-off-by: Lubomir Rintel --- src/qemu/qemu_capabilities.c | 4 ++-- src/qemu/qemu_command.c| 4 ++-- src/qemu/qemu_domain.c | 16 src/qemu/qemu_domain.h | 2 +- src/qemu/qemu_domain_address.c | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index f335a0149c..e025f50068 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1748,10 +1748,10 @@ bool virQEMUCapsHasPCIMultiBus(virQEMUCapsPtr qemuCaps, return false; } -/* If 'virt' supports PCI, it supports multibus. +/* If ARM 'virt' supports PCI, it supports multibus. * No extra conditions here for simplicity. */ -if (qemuDomainIsVirt(def)) +if (qemuDomainIsARMVirt(def)) return true; return false; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index bb956a77f4..e873cc8a20 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2909,7 +2909,7 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd, if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB && cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT && !qemuDomainIsQ35(def) && -!qemuDomainIsVirt(def)) { +!qemuDomainIsARMVirt(def)) { /* An appropriate default USB controller model should already * have been selected in qemuDomainDeviceDefPostParse(); if @@ -2947,7 +2947,7 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd, if (usbcontroller == 0 && !qemuDomainIsQ35(def) && -!qemuDomainIsVirt(def) && +!qemuDomainIsARMVirt(def) && !ARCH_IS_S390(def->os.arch)) { /* We haven't added any USB controller yet, but we haven't been asked * not to add one either. Add a legacy USB controller, unless we're diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 17177c3547..dfaba677b1 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3174,7 +3174,7 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def, case VIR_ARCH_AARCH64: addDefaultUSB = false; addDefaultMemballoon = false; -if (qemuDomainIsVirt(def)) +if (qemuDomainIsARMVirt(def)) addPCIeRoot = virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_GPEX); break; @@ -3355,7 +3355,7 @@ qemuDomainDefEnableDefaultFeatures(virDomainDefPtr def, * was not included in the domain XML, we need to choose a suitable * GIC version ourselves */ if ((def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ABSENT && - qemuDomainIsVirt(def)) || + qemuDomainIsARMVirt(def)) || (def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ON && def->gic_version == VIR_GIC_VERSION_NONE)) { virGICVersion version; @@ -3807,7 +3807,7 @@ qemuDomainDefValidateFeatures(const virDomainDef *def, case VIR_DOMAIN_FEATURE_GIC: if (def->features[i] == VIR_TRISTATE_SWITCH_ON && -!qemuDomainIsVirt(def)) { +!qemuDomainIsARMVirt(def)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("The '%s' feature is not supported for " "architecture '%s' or machine type '%s'"), @@ -4200,7 +4200,7 @@ qemuDomainChrDefValidate(const virDomainChrDef *dev, isCompatible = false; } -if (!qemuDomainIsVirt(def) && +if (!qemuDomainIsARMVirt(def) && (dev->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM || dev->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011)) { isCompatible = false; @@ -5572,7 +5572,7 @@ qemuDomainDefaultNetModel(const virDomainDef *def, if (STREQ(def->os.machine, "versatilepb")) return "smc91c111"; -if (qemuDomainIsVirt(def)) +if (qemuDomainIsARMVirt(def)) return "virtio"; /* Incomplete. vexpress (and a few others) use this, but not all @@ -5872,7 +5872,7 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr, chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA; } else if (qemuDomainIsPSeries(def)) { chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO; -} else if (qemuDomainIsVirt(def)) { +} else if (qemuDomainIsARMVirt(def)) { chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM; } else if (ARCH_IS_S390(def->os.arch)) { chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP; @@ -6066,7 +6066,7 @@ qemuDomainDeviceVideoDefPostParse(virD
[libvirt] [PATCH v2 08/11] tests/util: add RISC-V capabilities
Signed-off-by: Lubomir Rintel --- tests/testutilsqemu.c | 72 +++ 1 file changed, 72 insertions(+) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index dc7e90b952..c6376262b9 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -28,6 +28,8 @@ typedef enum { TEST_UTILS_QEMU_BIN_ARM, TEST_UTILS_QEMU_BIN_PPC64, TEST_UTILS_QEMU_BIN_PPC, +TEST_UTILS_QEMU_BIN_RISCV32, +TEST_UTILS_QEMU_BIN_RISCV64, TEST_UTILS_QEMU_BIN_S390X } QEMUBinType; @@ -38,6 +40,8 @@ static const char *QEMUBinList[] = { "/usr/bin/qemu-system-arm", "/usr/bin/qemu-system-ppc64", "/usr/bin/qemu-system-ppc", +"/usr/bin/qemu-system-riscv32", +"/usr/bin/qemu-system-riscv64", "/usr/bin/qemu-system-s390x" }; @@ -285,6 +289,68 @@ static int testQemuAddPPCGuest(virCapsPtr caps) return -1; } +static int testQemuAddRISCV32Guest(virCapsPtr caps) +{ +static const char *machine[] = { "spike_v1.10", + "spike_v1.9.1", + "sifive_e", + "virt", + "sifive_u" }; +virCapsGuestMachinePtr *machines = NULL; +virCapsGuestPtr guest; + +machines = virCapabilitiesAllocMachines(machine, 1); +if (!machines) +goto error; + +guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_RISCV32, +QEMUBinList[TEST_UTILS_QEMU_BIN_RISCV32], +NULL, 1, machines); +if (!guest) +goto error; + +if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, NULL)) +goto error; + +return 0; + + error: +/* No way to free a guest? */ +virCapabilitiesFreeMachines(machines, 1); +return -1; +} + +static int testQemuAddRISCV64Guest(virCapsPtr caps) +{ +static const char *machine[] = { "spike_v1.10", + "spike_v1.9.1", + "sifive_e", + "virt", + "sifive_u" }; +virCapsGuestMachinePtr *machines = NULL; +virCapsGuestPtr guest; + +machines = virCapabilitiesAllocMachines(machine, 1); +if (!machines) +goto error; + +guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_RISCV64, +QEMUBinList[TEST_UTILS_QEMU_BIN_RISCV64], +NULL, 1, machines); +if (!guest) +goto error; + +if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, NULL)) +goto error; + +return 0; + + error: +/* No way to free a guest? */ +virCapabilitiesFreeMachines(machines, 1); +return -1; +} + static int testQemuAddS390Guest(virCapsPtr caps) { static const char *s390_machines[] = { "s390-virtio", @@ -422,6 +488,12 @@ virCapsPtr testQemuCapsInit(void) if (testQemuAddPPCGuest(caps)) goto cleanup; +if (testQemuAddRISCV32Guest(caps)) +goto cleanup; + +if (testQemuAddRISCV64Guest(caps)) +goto cleanup; + if (testQemuAddS390Guest(caps)) goto cleanup; -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 03/11] util: add RISC-V architectures
Signed-off-by: Lubomir Rintel --- src/qemu/qemu_domain.c | 2 ++ src/util/virarch.c | 3 +++ src/util/virarch.h | 6 ++ 3 files changed, 11 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index dfaba677b1..275090fb58 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3224,6 +3224,8 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def, case VIR_ARCH_OR32: case VIR_ARCH_PARISC: case VIR_ARCH_PARISC64: +case VIR_ARCH_RISCV32: +case VIR_ARCH_RISCV64: case VIR_ARCH_PPCLE: case VIR_ARCH_UNICORE32: case VIR_ARCH_XTENSA: diff --git a/src/util/virarch.c b/src/util/virarch.c index be48bcfb89..77b893b0ac 100644 --- a/src/util/virarch.c +++ b/src/util/virarch.c @@ -65,6 +65,9 @@ static const struct virArchData { { "ppc64le", 64, VIR_ARCH_LITTLE_ENDIAN }, { "ppcemb", 32, VIR_ARCH_BIG_ENDIAN }, +{ "riscv32", 32, VIR_ARCH_LITTLE_ENDIAN }, +{ "riscv64", 64, VIR_ARCH_LITTLE_ENDIAN }, + { "s390", 32, VIR_ARCH_BIG_ENDIAN }, { "s390x",64, VIR_ARCH_BIG_ENDIAN }, { "sh4", 32, VIR_ARCH_LITTLE_ENDIAN }, diff --git a/src/util/virarch.h b/src/util/virarch.h index af5ff83528..806a23fade 100644 --- a/src/util/virarch.h +++ b/src/util/virarch.h @@ -55,6 +55,9 @@ typedef enum { VIR_ARCH_PPC64LE, /* PowerPC 64 LE http://en.wikipedia.org/wiki/PowerPC */ VIR_ARCH_PPCEMB, /* PowerPC 32 BE http://en.wikipedia.org/wiki/PowerPC */ +VIR_ARCH_RISCV32, /* RISC-V 64 LE http://en.wikipedia.org/wiki/RISC-V */ +VIR_ARCH_RISCV64, /* RISC-V 32 BE http://en.wikipedia.org/wiki/RISC-V */ + VIR_ARCH_S390, /* S39032 BE http://en.wikipedia.org/wiki/S390 */ VIR_ARCH_S390X,/* S39064 BE http://en.wikipedia.org/wiki/S390x */ VIR_ARCH_SH4, /* SuperH4 32 LE http://en.wikipedia.org/wiki/SuperH */ @@ -87,6 +90,9 @@ typedef enum { (arch) == VIR_ARCH_ARMV7B ||\ (arch) == VIR_ARCH_AARCH64) +# define ARCH_IS_RISCV(arch) ((arch) == VIR_ARCH_RISCV32 ||\ + (arch) == VIR_ARCH_RISCV64) + # define ARCH_IS_S390(arch) ((arch) == VIR_ARCH_S390 ||\ (arch) == VIR_ARCH_S390X) -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 11/11] tests/virschematest: add RISC-V to capabilityschemadata/caps-qemu-kvm
Signed-off-by: Lubomir Rintel --- tests/capabilityschemadata/caps-qemu-kvm.xml | 36 1 file changed, 36 insertions(+) diff --git a/tests/capabilityschemadata/caps-qemu-kvm.xml b/tests/capabilityschemadata/caps-qemu-kvm.xml index 88ec89e733..1aa98d140f 100644 --- a/tests/capabilityschemadata/caps-qemu-kvm.xml +++ b/tests/capabilityschemadata/caps-qemu-kvm.xml @@ -208,6 +208,42 @@ + +hvm + + 32 + /usr/bin/qemu-system-riscv32 + spike_v1.10 + spike_v1.9.1 + sifive_e + virt + sifive_u + + + + + + + + + +hvm + + 64 + /usr/bin/qemu-system-riscv64 + spike_v1.10 + spike_v1.9.1 + sifive_e + virt + sifive_u + + + + + + + + xen -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 09/11] tests/captest: check RISC-V capabilities lookup
Signed-off-by: Lubomir Rintel --- tests/vircapstest.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/tests/vircapstest.c b/tests/vircapstest.c index 1df3fa091f..e016e466d2 100644 --- a/tests/vircapstest.c +++ b/tests/vircapstest.c @@ -180,6 +180,12 @@ test_virCapsDomainDataLookupQEMU(const void *data ATTRIBUTE_UNUSED) CAPSCOMP(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_NONE, "/usr/bin/qemu-system-ppc64", NULL, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_PPC64, VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-ppc64", "pseries"); +CAPSCOMP(-1, VIR_ARCH_RISCV32, VIR_DOMAIN_VIRT_NONE, NULL, NULL, +VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_RISCV32, +VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-riscv32", "spike_v1.10"); +CAPSCOMP(-1, VIR_ARCH_RISCV64, VIR_DOMAIN_VIRT_NONE, NULL, NULL, +VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_RISCV64, +VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-riscv64", "spike_v1.10"); CAPSCOMP(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_NONE, NULL, "s390-virtio", VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_S390X, VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-s390x", -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 01/11] qemu: rename qemuDomainMachineIsVirt()
It's ARM specific. Signed-off-by: Lubomir Rintel --- src/qemu/qemu_capabilities.c | 2 +- src/qemu/qemu_domain.c | 6 +++--- src/qemu/qemu_domain.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 419208ad5c..f335a0149c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5134,7 +5134,7 @@ virQEMUCapsFillDomainFeatureGICCaps(virQEMUCapsPtr qemuCaps, virDomainCapsFeatureGICPtr gic = >gic; virGICVersion version; -if (!qemuDomainMachineIsVirt(domCaps->machine, domCaps->arch)) +if (!qemuDomainMachineIsARMVirt(domCaps->machine, domCaps->arch)) return 0; for (version = VIR_GIC_VERSION_LAST - 1; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2119233907..17177c3547 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9024,13 +9024,13 @@ qemuDomainMachineIsS390CCW(const char *machine) bool qemuDomainIsVirt(const virDomainDef *def) { -return qemuDomainMachineIsVirt(def->os.machine, def->os.arch); +return qemuDomainMachineIsARMVirt(def->os.machine, def->os.arch); } bool -qemuDomainMachineIsVirt(const char *machine, -const virArch arch) +qemuDomainMachineIsARMVirt(const char *machine, + const virArch arch) { if (arch != VIR_ARCH_ARMV7L && arch != VIR_ARCH_AARCH64) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index fd8d9b5305..c016d543a2 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -779,8 +779,8 @@ bool qemuDomainMachineIsQ35(const char *machine); bool qemuDomainMachineIsI440FX(const char *machine); bool qemuDomainMachineNeedsFDC(const char *machine); bool qemuDomainMachineIsS390CCW(const char *machine); -bool qemuDomainMachineIsVirt(const char *machine, - const virArch arch); +bool qemuDomainMachineIsARMVirt(const char *machine, +const virArch arch); bool qemuDomainMachineIsPSeries(const char *machine, const virArch arch); bool qemuDomainMachineHasBuiltinIDE(const char *machine); -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 05/11] qemu: no USB by default on RISC-V machines
Signed-off-by: Lubomir Rintel --- src/qemu/qemu_domain.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 275090fb58..72b72364d5 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3198,6 +3198,11 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def, addPCIRoot = true; break; +case VIR_ARCH_RISCV32: +case VIR_ARCH_RISCV64: +addDefaultUSB = false; +break; + case VIR_ARCH_S390: case VIR_ARCH_S390X: addDefaultUSB = false; @@ -3224,8 +3229,6 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def, case VIR_ARCH_OR32: case VIR_ARCH_PARISC: case VIR_ARCH_PARISC64: -case VIR_ARCH_RISCV32: -case VIR_ARCH_RISCV64: case VIR_ARCH_PPCLE: case VIR_ARCH_UNICORE32: case VIR_ARCH_XTENSA: -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 00/11] RISC-V Guest Support
Hello, here's a second version of the RISV-V support patch set, initally submitted just under a month ago [1]. [1] https://www.redhat.com/archives/libvir-list/2018-May/thread.html#01008 Thanks to the Andrea's suggestions the patch is now considerably thinner, and split to hopefully more manageable changes. Aside from the test suite, my test case is this (with images from [2]): virt-install \ --import --name riscv64 \ --arch riscv64 --machine virt \ --memory 2048 \ --rng /dev/urandom \ --disk /var/lib/libvirt/images/stage4-disk.img,bus=virtio \ --boot kernel=/var/lib/libvirt/images/bbl,kernel_args="console=ttyS0 ro root=/dev/vda" [2] https://fedorapeople.org/groups/risc-v/disk-images/ Note that the large test suite changes that touch the '*.replies' files seem to upset the mail server, thus you're unlikely to receive them from the list. You can get them straight from my repository instead: git fetch https://github.com/lkundrak/libvirt.git lr/riscv-v2:riscv-v2 git checkout riscv-v2 Thanks! Lubo Diffstat follows. Lubomir Rintel (11): qemu: rename qemuDomainMachineIsVirt() qemu: rename qemuDomainArmVirt() util: add RISC-V architectures docs/schemas: add RISC-V architectures qemu: no USB by default on RISC-V machines qemu: assign addresses to virtio devices on RISC-V tests/capabilitiestest: add RISC-V capability tests tests/util: add RISC-V capabilities tests/captest: check RISC-V capabilities lookup tests/qemuxml2argvtest: test RISC-V virt machine arguments tests/virschematest: add RISC-V to capabilityschemadata/caps-qemu-kvm docs/schemas/basictypes.rng | 2 + src/qemu/qemu_capabilities.c | 6 +- src/qemu/qemu_command.c | 4 +- src/qemu/qemu_domain.c|27 +- src/qemu/qemu_domain.h| 6 +- src/qemu/qemu_domain_address.c|23 +- src/util/virarch.c| 3 + src/util/virarch.h| 6 + tests/capabilityschemadata/caps-qemu-kvm.xml |36 + .../caps_2.12.0.riscv32.replies | 14679 .../caps_2.12.0.riscv32.xml | 126 + .../caps_2.12.0.riscv64.replies | 14679 .../caps_2.12.0.riscv64.xml | 126 + tests/qemucapabilitiestest.c | 2 + tests/qemuxml2argvdata/riscv64-virt.args |31 + tests/qemuxml2argvdata/riscv64-virt.xml |32 + tests/qemuxml2argvtest.c | 3 + .../riscv64-virt.xml |39 + tests/testutilsqemu.c |72 + tests/vircapstest.c | 6 + 20 files changed, 29887 insertions(+), 21 deletions(-) create mode 100644 tests/qemucapabilitiesdata/caps_2.12.0.riscv32.replies create mode 100644 tests/qemucapabilitiesdata/caps_2.12.0.riscv32.xml create mode 100644 tests/qemucapabilitiesdata/caps_2.12.0.riscv64.replies create mode 100644 tests/qemucapabilitiesdata/caps_2.12.0.riscv64.xml create mode 100644 tests/qemuxml2argvdata/riscv64-virt.args create mode 100644 tests/qemuxml2argvdata/riscv64-virt.xml create mode 100644 tests/qemuxml2startupxmloutdata/riscv64-virt.xml -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 8/9] tests/qemuxml2argvtest: test RISC-V virt machine arguments
I am not sure whether this test makes sense. The generated command line is indeed sensible, but other tests seem to focus on testing particular devices as opposed to an overall check of a machine. Signed-off-by: Lubomir Rintel <lkund...@v3.sk> --- tests/qemuxml2argvdata/riscv64-virt.args | 29 +++ tests/qemuxml2argvdata/riscv64-virt.xml | 34 + tests/qemuxml2argvtest.c | 2 + .../riscv64-virt.xml | 37 +++ 4 files changed, 102 insertions(+) create mode 100644 tests/qemuxml2argvdata/riscv64-virt.args create mode 100644 tests/qemuxml2argvdata/riscv64-virt.xml create mode 100644 tests/qemuxml2startupxmloutdata/riscv64-virt.xml diff --git a/tests/qemuxml2argvdata/riscv64-virt.args b/tests/qemuxml2argvdata/riscv64-virt.args new file mode 100644 index 00..0404afdd27 --- /dev/null +++ b/tests/qemuxml2argvdata/riscv64-virt.args @@ -0,0 +1,29 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-riscv64 \ +-name riscv64 \ +-S \ +-machine virt,accel=tcg,usb=off,dump-guest-core=off \ +-m 2048 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid fd65fc03-8838-4c4d-9d8d-395802488790 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-riscv64/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-boot c \ +-kernel /var/lib/libvirt/images/bbl \ +-append 'console=ttyS0 ro root=/dev/vda' \ +-drive file=/var/lib/libvirt/images/stage4-disk.img,format=raw,if=none,\ +id=drive-virtio-disk0 \ +-device virtio-blk-device,drive=drive-virtio-disk0,id=virtio-disk0 \ +-chardev pty,id=charserial0 \ +-serial chardev:charserial0 diff --git a/tests/qemuxml2argvdata/riscv64-virt.xml b/tests/qemuxml2argvdata/riscv64-virt.xml new file mode 100644 index 00..0b6d668ebe --- /dev/null +++ b/tests/qemuxml2argvdata/riscv64-virt.xml @@ -0,0 +1,34 @@ + + riscv64 + fd65fc03-8838-4c4d-9d8d-395802488790 + 2097152 + 2097152 + 1 + +hvm +/var/lib/libvirt/images/bbl +console=ttyS0 ro root=/dev/vda + + + + destroy + restart + destroy + +/usr/bin/qemu-system-riscv64 + + + + + + + + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 042ee12aaa..b02d70a854 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2843,6 +2843,8 @@ mymain(void) QEMU_CAPS_DEVICE_VIRTIO_MOUSE_CCW, QEMU_CAPS_DEVICE_VIRTIO_TABLET_CCW); +DO_TEST("riscv64-virt", NONE); + if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL) virFileDeleteTree(fakerootdir); diff --git a/tests/qemuxml2startupxmloutdata/riscv64-virt.xml b/tests/qemuxml2startupxmloutdata/riscv64-virt.xml new file mode 100644 index 00..f635862792 --- /dev/null +++ b/tests/qemuxml2startupxmloutdata/riscv64-virt.xml @@ -0,0 +1,37 @@ + + riscv64 + fd65fc03-8838-4c4d-9d8d-395802488790 + 2097152 + 2097152 + 1 + +hvm +/var/lib/libvirt/images/bbl +console=ttyS0 ro root=/dev/vda + + + + destroy + restart + destroy + +/usr/bin/qemu-system-riscv64 + + + + + + + + + + + + + + + + + + + -- 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 6/9] tests/util: add RISC-V capabilities
Signed-off-by: Lubomir Rintel <lkund...@v3.sk> --- tests/testutilsqemu.c | 72 +++ 1 file changed, 72 insertions(+) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index dc7e90b952..c6376262b9 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -28,6 +28,8 @@ typedef enum { TEST_UTILS_QEMU_BIN_ARM, TEST_UTILS_QEMU_BIN_PPC64, TEST_UTILS_QEMU_BIN_PPC, +TEST_UTILS_QEMU_BIN_RISCV32, +TEST_UTILS_QEMU_BIN_RISCV64, TEST_UTILS_QEMU_BIN_S390X } QEMUBinType; @@ -38,6 +40,8 @@ static const char *QEMUBinList[] = { "/usr/bin/qemu-system-arm", "/usr/bin/qemu-system-ppc64", "/usr/bin/qemu-system-ppc", +"/usr/bin/qemu-system-riscv32", +"/usr/bin/qemu-system-riscv64", "/usr/bin/qemu-system-s390x" }; @@ -285,6 +289,68 @@ static int testQemuAddPPCGuest(virCapsPtr caps) return -1; } +static int testQemuAddRISCV32Guest(virCapsPtr caps) +{ +static const char *machine[] = { "spike_v1.10", + "spike_v1.9.1", + "sifive_e", + "virt", + "sifive_u" }; +virCapsGuestMachinePtr *machines = NULL; +virCapsGuestPtr guest; + +machines = virCapabilitiesAllocMachines(machine, 1); +if (!machines) +goto error; + +guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_RISCV32, +QEMUBinList[TEST_UTILS_QEMU_BIN_RISCV32], +NULL, 1, machines); +if (!guest) +goto error; + +if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, NULL)) +goto error; + +return 0; + + error: +/* No way to free a guest? */ +virCapabilitiesFreeMachines(machines, 1); +return -1; +} + +static int testQemuAddRISCV64Guest(virCapsPtr caps) +{ +static const char *machine[] = { "spike_v1.10", + "spike_v1.9.1", + "sifive_e", + "virt", + "sifive_u" }; +virCapsGuestMachinePtr *machines = NULL; +virCapsGuestPtr guest; + +machines = virCapabilitiesAllocMachines(machine, 1); +if (!machines) +goto error; + +guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_RISCV64, +QEMUBinList[TEST_UTILS_QEMU_BIN_RISCV64], +NULL, 1, machines); +if (!guest) +goto error; + +if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, NULL)) +goto error; + +return 0; + + error: +/* No way to free a guest? */ +virCapabilitiesFreeMachines(machines, 1); +return -1; +} + static int testQemuAddS390Guest(virCapsPtr caps) { static const char *s390_machines[] = { "s390-virtio", @@ -422,6 +488,12 @@ virCapsPtr testQemuCapsInit(void) if (testQemuAddPPCGuest(caps)) goto cleanup; +if (testQemuAddRISCV32Guest(caps)) +goto cleanup; + +if (testQemuAddRISCV64Guest(caps)) +goto cleanup; + if (testQemuAddS390Guest(caps)) goto cleanup; -- 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 9/9] tests/virschematest: add RISC-V to capabilityschemadata/caps-qemu-kvm
Signed-off-by: Lubomir Rintel <lkund...@v3.sk> --- tests/capabilityschemadata/caps-qemu-kvm.xml | 36 1 file changed, 36 insertions(+) diff --git a/tests/capabilityschemadata/caps-qemu-kvm.xml b/tests/capabilityschemadata/caps-qemu-kvm.xml index 652061b606..466ad2cdbe 100644 --- a/tests/capabilityschemadata/caps-qemu-kvm.xml +++ b/tests/capabilityschemadata/caps-qemu-kvm.xml @@ -207,6 +207,42 @@ + +hvm + + 32 + /usr/bin/qemu-system-riscv32 + spike_v1.10 + spike_v1.9.1 + sifive_e + virt + sifive_u + + + + + + + + + +hvm + + 64 + /usr/bin/qemu-system-riscv64 + spike_v1.10 + spike_v1.9.1 + sifive_e + virt + sifive_u + + + + + + + + xen -- 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 0/9] RISC-V Guest Support
Hello, here's patches I've used in order to be able to run RISC-V guests with libvirtd. In case you're interested in having RISC-V support you may want to have a look. There are some problems I am aware of, though not really able to address. I might be wrong about some points -- whoever is more familiar with QEMU, RISC-V or libvirt please correct me: * Essentially only the "virt" machine is useful, because others don't seem to support storage or network (as of qemu-2.12). It is not default though, so creating a reasonable guest configuration is not intuitive. * The serial port used by the "virt" machine is NS16550A connected to the platform bus, but it doesn't seem to appear in the QEMU device model. I hardcoded it in qemuChrIsPlatformDevice() and qemuDomainChrDefPostParse() so that we end up defaulting to the correct one for the virt machine. * The tests were in a large part cargo-culted. I made some effort to cover what I thought was important, but it likely needs a better pair of eyes than mine. More in the idividual patches. In any case, I am able to boot Fedora and things seem to work well in general. I'll be thankful for feedback (and even more thankful if anyone more familiar with libvirtd picks up the patchset :). Hope this is useful, Lubo Diffstat follows. Lubomir Rintel (9): conf: add an option to specify a NS16550A serial port qemu: enable GIC only on AArch64 qemu: rename qemuDomainAssignARMVirtioMMIOAddresses() util: add RISC-V support tests/capabilitiestest: add RISC-V capability tests tests/util: add RISC-V capabilities tests/captest: check RISC-V capabilities lookup tests/qemuxml2argvtest: test RISC-V virt machine arguments tests/virschematest: add RISC-V to capabilityschemadata/caps-qemu-kvm docs/schemas/basictypes.rng | 2 + docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c| 1 + src/conf/domain_conf.h| 1 + src/qemu/qemu_command.c |17 +- src/qemu/qemu_domain.c|24 +- src/qemu/qemu_domain_address.c|27 +- src/util/virarch.c| 3 + src/util/virarch.h| 6 + tests/capabilityschemadata/caps-qemu-kvm.xml |36 + .../caps_2.12.0.riscv32.replies | 14420 .../caps_2.12.0.riscv32.xml | 119 + .../caps_2.12.0.riscv64.replies | 14420 .../caps_2.12.0.riscv64.xml | 119 + tests/qemucapabilitiestest.c | 2 + tests/qemuxml2argvdata/riscv64-virt.args |29 + tests/qemuxml2argvdata/riscv64-virt.xml |34 + tests/qemuxml2argvtest.c | 2 + .../riscv64-virt.xml |37 + tests/testutilsqemu.c |72 + tests/vircapstest.c | 6 + 21 files changed, 29354 insertions(+), 24 deletions(-) create mode 100644 tests/qemucapabilitiesdata/caps_2.12.0.riscv32.replies create mode 100644 tests/qemucapabilitiesdata/caps_2.12.0.riscv32.xml create mode 100644 tests/qemucapabilitiesdata/caps_2.12.0.riscv64.replies create mode 100644 tests/qemucapabilitiesdata/caps_2.12.0.riscv64.xml create mode 100644 tests/qemuxml2argvdata/riscv64-virt.args create mode 100644 tests/qemuxml2argvdata/riscv64-virt.xml create mode 100644 tests/qemuxml2startupxmloutdata/riscv64-virt.xml -- 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 4/9] util: add RISC-V support
What works, with images from [1]: virt-install \ --import --name riscv64 \ --arch riscv64 --machine virt \ --memory 2048 \ --rng /dev/urandom \ --disk /var/lib/libvirt/images/stage4-disk.img,bus=virtio \ --boot kernel=/var/lib/libvirt/images/bbl,kernel_args="console=ttyS0 ro root=/dev/vda" [1] https://fedorapeople.org/groups/risc-v/disk-images/ Signed-off-by: Lubomir Rintel <lkund...@v3.sk> --- docs/schemas/basictypes.rng| 2 ++ src/qemu/qemu_command.c| 15 --- src/qemu/qemu_domain.c | 18 +++--- src/qemu/qemu_domain_address.c | 21 +++-- src/util/virarch.c | 3 +++ src/util/virarch.h | 6 ++ 6 files changed, 45 insertions(+), 20 deletions(-) diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng index 1a18cd31b1..14a3670e5c 100644 --- a/docs/schemas/basictypes.rng +++ b/docs/schemas/basictypes.rng @@ -398,6 +398,8 @@ ppc64 ppc64le ppcemb + riscv32 + riscv64 s390 s390x sh4 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f91d3ae5ac..12f90521d4 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8940,14 +8940,15 @@ static bool qemuChrIsPlatformDevice(const virDomainDef *def, virDomainChrDefPtr chr) { -if (def->os.arch == VIR_ARCH_ARMV7L || def->os.arch == VIR_ARCH_AARCH64) { - -/* pl011 (used on mach-virt) is a platform device */ -if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && -chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM && -chr->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011) { +if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && +chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM) { +if ((def->os.arch == VIR_ARCH_ARMV7L || def->os.arch == VIR_ARCH_AARCH64) && +chr->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011) +return true; +if (ARCH_IS_RISCV(def->os.arch) && +qemuDomainIsVirt(def) && +chr->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NS16550A) return true; -} } /* If we got all the way here and we're still stuck with the default diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index db73f45204..20d05da9c4 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2914,6 +2914,14 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def, case VIR_ARCH_PARISC: case VIR_ARCH_PARISC64: case VIR_ARCH_PPCLE: +break; + +case VIR_ARCH_RISCV32: +case VIR_ARCH_RISCV64: +addDefaultUSB = false; +addDefaultMemballoon = false; +break; + case VIR_ARCH_UNICORE32: case VIR_ARCH_XTENSA: case VIR_ARCH_XTENSAEB: @@ -5138,7 +5146,7 @@ static const char * qemuDomainDefaultNetModel(const virDomainDef *def, virQEMUCapsPtr qemuCaps) { -if (ARCH_IS_S390(def->os.arch)) +if (ARCH_IS_S390(def->os.arch) || ARCH_IS_RISCV(def->os.arch)) return "virtio"; if (def->os.arch == VIR_ARCH_ARMV7L || @@ -5470,7 +5478,10 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr, chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY; break; case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM: -chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011; +if (ARCH_IS_RISCV(def->os.arch)) +chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NS16550A; +else +chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011; break; case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP: chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE; @@ -8449,7 +8460,8 @@ qemuDomainMachineIsVirt(const char *machine, const virArch arch) { if (arch != VIR_ARCH_ARMV7L && -arch != VIR_ARCH_AARCH64) +arch != VIR_ARCH_AARCH64 && +!ARCH_IS_RISCV(arch)) return false; if (STRNEQ(machine, "virt") && diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 87e1dc3bd2..5d9a073d25 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -480,13 +480,13 @@ static void qemuDomainAssignVirtioMMIOAddresses(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) { -if (def->os.arch != VIR_ARCH_ARMV7L && -def->os.arch != VIR_ARCH_AARCH64) -return; - -if (!(STRPREFIX(def->os.machine, "vexpress-") || - qemuDomainIsVirt(def))) +if (def->os.arch == VIR
[libvirt] [PATCH 2/9] qemu: enable GIC only on AArch64
Other "virt" type machines don't support it. Signed-off-by: Lubomir Rintel <lkund...@v3.sk> --- src/qemu/qemu_domain.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 97633bfbb9..db73f45204 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3044,6 +3044,7 @@ qemuDomainDefEnableDefaultFeatures(virDomainDefPtr def, * was not included in the domain XML, we need to choose a suitable * GIC version ourselves */ if ((def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ABSENT && + def->os.arch == VIR_ARCH_AARCH64 && qemuDomainIsVirt(def)) || (def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ON && def->gic_version == VIR_GIC_VERSION_NONE)) { -- 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/9] qemu: rename qemuDomainAssignARMVirtioMMIOAddresses()
Having a MMIO VirtIO interface is not specific to ARM. RISC-V can use it too. Signed-off-by: Lubomir Rintel <lkund...@v3.sk> --- src/qemu/qemu_domain_address.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index b7c82cb6f1..87e1dc3bd2 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -477,8 +477,8 @@ qemuDomainHasVirtioMMIODevices(virDomainDefPtr def) static void -qemuDomainAssignARMVirtioMMIOAddresses(virDomainDefPtr def, - virQEMUCapsPtr qemuCaps) +qemuDomainAssignVirtioMMIOAddresses(virDomainDefPtr def, +virQEMUCapsPtr qemuCaps) { if (def->os.arch != VIR_ARCH_ARMV7L && def->os.arch != VIR_ARCH_AARCH64) @@ -2927,7 +2927,7 @@ qemuDomainAssignAddresses(virDomainDefPtr def, if (qemuDomainAssignS390Addresses(def, qemuCaps) < 0) return -1; -qemuDomainAssignARMVirtioMMIOAddresses(def, qemuCaps); +qemuDomainAssignVirtioMMIOAddresses(def, qemuCaps); if (qemuDomainAssignPCIAddresses(def, qemuCaps, driver, obj) < 0) return -1; -- 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 7/9] tests/captest: check RISC-V capabilities lookup
I actually am unsure what this test checks apart from that the RISCV machines default to HVM and spike_v1.10 machine. Signed-off-by: Lubomir Rintel <lkund...@v3.sk> --- tests/vircapstest.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/tests/vircapstest.c b/tests/vircapstest.c index 1df3fa091f..e016e466d2 100644 --- a/tests/vircapstest.c +++ b/tests/vircapstest.c @@ -180,6 +180,12 @@ test_virCapsDomainDataLookupQEMU(const void *data ATTRIBUTE_UNUSED) CAPSCOMP(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_NONE, "/usr/bin/qemu-system-ppc64", NULL, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_PPC64, VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-ppc64", "pseries"); +CAPSCOMP(-1, VIR_ARCH_RISCV32, VIR_DOMAIN_VIRT_NONE, NULL, NULL, +VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_RISCV32, +VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-riscv32", "spike_v1.10"); +CAPSCOMP(-1, VIR_ARCH_RISCV64, VIR_DOMAIN_VIRT_NONE, NULL, NULL, +VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_RISCV64, +VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-riscv64", "spike_v1.10"); CAPSCOMP(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_NONE, NULL, "s390-virtio", VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_S390X, VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-s390x", -- 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/9] conf: add an option to specify a NS16550A serial port
QEMU attaches this to a riscv/virt board. It's perhaps the same thing as used on x86/pc, somewhat unfortunately called model="isa-serial". Signed-off-by: Lubomir Rintel <lkund...@v3.sk> --- docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c| 1 + src/conf/domain_conf.h| 1 + src/qemu/qemu_command.c | 2 ++ src/qemu/qemu_domain.c| 5 - 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index ff539607cc..47d4ee28ff 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3631,6 +3631,7 @@ pci-serial spapr-vty pl011 + ns16550a sclpconsole sclplmconsole diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d38a775f21..119a074a0a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -486,6 +486,7 @@ VIR_ENUM_IMPL(virDomainChrSerialTargetModel, "pci-serial", "spapr-vty", "pl011", + "ns16550a", "sclpconsole", "sclplmconsole", ); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 07d04fb2f9..c00293a07b 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1125,6 +1125,7 @@ typedef enum { VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL, VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY, VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011, +VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NS16550A, VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE, VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE, diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 0727361f19..f91d3ae5ac 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8909,6 +8909,7 @@ qemuChrSerialTargetModelToCaps(virDomainChrSerialTargetModel targetModel) return QEMU_CAPS_DEVICE_SCLPLMCONSOLE; case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011: return QEMU_CAPS_DEVICE_PL011; +case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NS16550A: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: break; @@ -10200,6 +10201,7 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, break; case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011: +case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NS16550A: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: /* Except from _LAST, which is just a guard value and will never diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 8d0ab9788f..97633bfbb9 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3724,6 +3724,7 @@ qemuDomainChrSerialTargetModelToTargetType(int targetModel) case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY: return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO; case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011: +case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NS16550A: return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM; case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE: @@ -3787,6 +3788,7 @@ qemuDomainChrTargetDefValidate(const virDomainChrDef *chr) case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011: +case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NS16550A: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE: @@ -3847,7 +3849,8 @@ qemuDomainChrDefValidate(const virDomainChrDef *dev, if (!qemuDomainIsVirt(def) && (dev->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM || - dev->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011)) { + dev->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011 || + dev->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NS16550A)) { isCompatible = false; } -- 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/2] lxc: move wireless PHYs to a network namespace
On Thu, 2015-04-16 at 17:23 +0200, Michal Privoznik wrote: On 14.04.2015 18:21, Lubomir Rintel wrote: The 802.11 interfaces can not be moved by themselves, their Phy has to move too. If there are other interfaces, they have to move too -- hopefully it's not too confusing. This is a less-invasive alternative to defining a new hostdev type for PHYs. --- src/util/virnetdev.c | 31 +++ 1 file changed, 31 insertions(+) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index ee60f09..df48763 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -584,6 +584,8 @@ int virNetDevSetNamespace(const char *ifname, pid_t pidInNs) { int rc; char *pid = NULL; +char *phy_path = NULL; + const char *argv[] = { ip, link, set, ifname, netns, NULL, NULL }; @@ -591,6 +593,35 @@ int virNetDevSetNamespace(const char *ifname, pid_t pidInNs) if (virAsprintf(pid, %lld, (long long) pidInNs) == -1) return -1; +/* The 802.11 wireless devices only move together with their PHY. */ +if (virNetDevSysfsFile(phy_path, ifname, phy80211/name) = 0) { +int len; +char *phy = NULL; + +len = virFileReadAllQuiet(phy_path, 1024, phy); +VIR_FREE(phy_path); + +/* Remove a line break. */ +if (len 0) +phy[len - 1] = '\0'; + +if (len = 0) { +const char *iwargv[] = { +iw, phy, phy, set, netns, NULL, NULL +}; + +iwargv[5] = pid; +rc = virRun(iwargv, NULL); + +VIR_FREE(phy); + +if (rc == 0) { +VIR_FREE(pid); +return rc; +} +} +} + argv[5] = pid; rc = virRun(argv, NULL); I understand what you mean, but the code style could be better. I'm not too sure. You reversed the logic with your changes and now it no longer works. It's quite expected for ip link set to fail for a 802.11 device -- you must not fail in that case. I'll polish and resend the patch in your name. Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] virnetdev: fix moving of 802.11 phys
There was a couple of problems with the style fixes applied to the original patch: 1.) virFileReadAllQuiet comparison was incorrectly parenthesized when moved into a condition, causing the len to be set to the result of comparison. This, together with the removed underflow check would underflow the phy buffer. 2.) The logic was broken. Failure to call ip would abort the function, thus the iw branch would never be reached. This aims to fix the issues and work around possible style complains :) Signed-off-by: Lubomir Rintel lkund...@v3.sk --- src/util/virnetdev.c | 46 +- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 98ce152..e4fcd81 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -478,40 +478,36 @@ int virNetDevSetNamespace(const char *ifname, pid_t pidInNs) char *phy_path = NULL; int len; -const char *argv[] = { -ip, link, set, ifname, netns, NULL, NULL -}; - -const char *iwargv[] = { -iw, phy, NULL, set, netns, NULL, NULL -}; - if (virAsprintf(pid, %lld, (long long) pidInNs) == -1) return -1; -argv[5] = pid; -if (virRun(argv, NULL) 0) -goto cleanup; - /* The 802.11 wireless devices only move together with their PHY. */ if (virNetDevSysfsFile(phy_path, ifname, phy80211/name) 0) goto cleanup; -if ((len = virFileReadAllQuiet(phy_path, 1024, phy) 0)) { -if (errno == ENOENT) { -/* Okay, this is not a wireless card. Claim success. */ -ret = 0; -} -goto cleanup; -} +if ((len = virFileReadAllQuiet(phy_path, 1024, phy)) = 0) { +/* Not a wireless device. */ +const char *argv[] = { +ip, link, set, ifname, netns, NULL, NULL +}; -/* Remove a line break. */ -phy[len - 1] = '\0'; +argv[5] = pid; +if (virRun(argv, NULL) 0) +goto cleanup; -iwargv[2] = phy; -iwargv[5] = pid; -if (virRun(iwargv, NULL) 0) -goto cleanup; +} else { +const char *argv[] = { +iw, phy, NULL, set, netns, NULL, NULL +}; + +/* Remove a line break. */ +phy[len - 1] = '\0'; + +argv[2] = phy; +argv[5] = pid; +if (virRun(argv, NULL) 0) +goto cleanup; +} ret = 0; cleanup: -- 2.4.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH libvirt] interface: don't error out if a bond has no interfaces
It's not a problem at all and causes virt-manager to break down. Note: netcf 0.2.8 generates invalid XML for a bond with no interfaces anyway, so this error is in fact not reached as we fail earlier. Fix submitted upstream. Signed-off-by: Lubomir Rintel lkund...@v3.sk --- src/conf/interface_conf.c | 16 ++-- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index c2eb945..29769ac 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -553,19 +553,15 @@ virInterfaceDefParseBondItfs(virInterfaceDefPtr def, nbItf = virXPathNodeSet(./interface, ctxt, interfaces); if (nbItf 0) { ret = -1; -goto error; +goto cleanup; } -if (nbItf == 0) { -virReportError(VIR_ERR_XML_ERROR, - %s, _(bond has no interfaces)); -ret = -1; -goto error; -} +if (nbItf == 0) +goto cleanup; if (VIR_ALLOC_N(def-data.bond.itf, nbItf) 0) { ret = -1; -goto error; +goto cleanup; } def-data.bond.nbItf = nbItf; @@ -575,12 +571,12 @@ virInterfaceDefParseBondItfs(virInterfaceDefPtr def, if (itf == NULL) { ret = -1; def-data.bond.nbItf = i; -goto error; +goto cleanup; } def-data.bond.itf[i] = itf; } - error: + cleanup: VIR_FREE(interfaces); ctxt-node = bond; return ret; -- 2.4.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2] lxc: don't up the veth interfaces unless explicitly asked to
Upping an interface for no reason and not configuring it is a cardinal sin. With the default addrgenmode if eui64 it sticks a link-local address to the interface. That is not good, as NetworkManager would see an address configured, assume the interface is already configured and won't touch it iself and the interface might stay unconfigured until the end of the days. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1124721 --- src/lxc/lxc_container.c | 2 +- src/lxc/lxc_native.c| 10 -- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index cc20b6d..bd135c7 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -541,7 +541,7 @@ static int lxcContainerRenameAndEnableInterfaces(virDomainDefPtr vmDef, VIR_FREE(ipStr); } -if (netDef-linkstate != VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN) { +if (netDef-nips || netDef-linkstate == VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP) { VIR_DEBUG(Enabling %s, newname); rc = virNetDevSetOnline(newname, true); if (rc 0) diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index c15eb19..2297dbe 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -348,12 +348,10 @@ lxcCreateNetDef(const char *type, if (VIR_ALLOC(net) 0) goto error; -if (flag) { -if (STREQ(flag, up)) -net-linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP; -else -net-linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN; -} +if (flag STREQ(flag, up)) +net-linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP; +else +net-linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN; if (VIR_STRDUP(net-ifname_guest, name) 0) goto error; -- 2.3.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] lxc: don't up the veth interfaces unless explicitly asked to
Upping an interface for no reason and not configuring it is a cardinal sin. With the default addrgenmode if eui64 it sticks a link-local address to the interface. That is not good, as NetworkManager would see an address configured, assume the interface is already configured and won't touch it iself and the interface might stay unconfigured until the end of the days. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1124721 --- src/lxc/lxc_container.c | 2 +- src/lxc/lxc_native.c| 10 -- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index cc20b6d..50e38e9 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -541,7 +541,7 @@ static int lxcContainerRenameAndEnableInterfaces(virDomainDefPtr vmDef, VIR_FREE(ipStr); } -if (netDef-linkstate != VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN) { +if (netDef-linkstate == VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP) { VIR_DEBUG(Enabling %s, newname); rc = virNetDevSetOnline(newname, true); if (rc 0) diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index c15eb19..2297dbe 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -348,12 +348,10 @@ lxcCreateNetDef(const char *type, if (VIR_ALLOC(net) 0) goto error; -if (flag) { -if (STREQ(flag, up)) -net-linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP; -else -net-linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN; -} +if (flag STREQ(flag, up)) +net-linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP; +else +net-linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN; if (VIR_STRDUP(net-ifname_guest, name) 0) goto error; -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/2] virnetdev: move virNetDevSysfsFile() upwards
...and provide a bogus implementation for non-Linux. No functional change. We'd like to use it from within virNetDevSetNamespace() to determine if we need to move a 802.11 PHY to a namespace when moving the interface. --- src/util/virnetdev.c | 34 ++ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 9a6d4e7..ee60f09 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -114,6 +114,28 @@ struct _virNetDevMcastList { virNetDevMcastEntryPtr *entries; }; +#ifdef __linux__ +# define NET_SYSFS /sys/class/net/ + +static int +virNetDevSysfsFile(char **pf_sysfs_device_link, const char *ifname, + const char *file) +{ + +if (virAsprintf(pf_sysfs_device_link, NET_SYSFS %s/%s, ifname, file) 0) +return -1; +return 0; +} +#else +static int +virNetDevSysfsFile(char **pf_sysfs_device_link, const char *ifname, + const char *file) +{ +return -1; +} +#endif + + #if defined(HAVE_STRUCT_IFREQ) static int virNetDevSetupControlFull(const char *ifname, struct ifreq *ifr, @@ -1612,18 +1634,6 @@ int virNetDevValidateConfig(const char *ifname ATTRIBUTE_UNUSED, #ifdef __linux__ -# define NET_SYSFS /sys/class/net/ - -static int -virNetDevSysfsFile(char **pf_sysfs_device_link, const char *ifname, - const char *file) -{ - -if (virAsprintf(pf_sysfs_device_link, NET_SYSFS %s/%s, ifname, file) 0) -return -1; -return 0; -} - static int virNetDevSysfsDeviceFile(char **pf_sysfs_device_link, const char *ifname, const char *file) -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/2] lxc: move wireless PHYs to a network namespace
The 802.11 interfaces can not be moved by themselves, their Phy has to move too. If there are other interfaces, they have to move too -- hopefully it's not too confusing. This is a less-invasive alternative to defining a new hostdev type for PHYs. --- src/util/virnetdev.c | 31 +++ 1 file changed, 31 insertions(+) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index ee60f09..df48763 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -584,6 +584,8 @@ int virNetDevSetNamespace(const char *ifname, pid_t pidInNs) { int rc; char *pid = NULL; +char *phy_path = NULL; + const char *argv[] = { ip, link, set, ifname, netns, NULL, NULL }; @@ -591,6 +593,35 @@ int virNetDevSetNamespace(const char *ifname, pid_t pidInNs) if (virAsprintf(pid, %lld, (long long) pidInNs) == -1) return -1; +/* The 802.11 wireless devices only move together with their PHY. */ +if (virNetDevSysfsFile(phy_path, ifname, phy80211/name) = 0) { +int len; +char *phy = NULL; + +len = virFileReadAllQuiet(phy_path, 1024, phy); +VIR_FREE(phy_path); + +/* Remove a line break. */ +if (len 0) +phy[len - 1] = '\0'; + +if (len = 0) { +const char *iwargv[] = { +iw, phy, phy, set, netns, NULL, NULL +}; + +iwargv[5] = pid; +rc = virRun(iwargv, NULL); + +VIR_FREE(phy); + +if (rc == 0) { +VIR_FREE(pid); +return rc; +} +} +} + argv[5] = pid; rc = virRun(argv, NULL); -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 0/2] lxc: allow using 802.11 wireless interfaces in LXC domains
Hi, I'm using libvirt-lxc with mac80211_hwsim to construct virtual wireless network for NetworkManager testing. Currently, I have to move the interfaces to the domains manually, as sharing wan 802.11 wireless link with a LXC namespace does not work: hostdev mode='capabilities' type='net' sourceinterfacewlan0/interface/source /hostdev The wireless links can only be associated to namespaces by moving the underlying PHY instead of the network interface. I'm following up with patches that fix the problem for me; please take a look. Thank you Lubo -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2] lxc: create the required directories upon driver start
/var/run may reside on a tmpfs and we fail to create the PID file if /var/run/lxc does not exist. [cbosdon...@suse.com: use cfg-stateDir instead of LXC_STATE_DIR] Signed-off-by: Lubomir Rintel lkund...@v3.sk --- src/lxc/lxc_driver.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 245000d..8dfa686 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1648,6 +1648,13 @@ static int lxcStateInitialize(bool privileged, if (!(caps = virLXCDriverGetCapabilities(lxc_driver, false))) goto cleanup; +if (virFileMakePath(cfg-stateDir) 0) { +virReportSystemError(errno, + _(Failed to mkdir %s), + cfg-stateDir); +goto cleanup; +} + /* Get all the running persistent or transient configs first */ if (virDomainObjListLoadAllConfigs(lxc_driver-domains, cfg-stateDir, -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] lxc: create the required directories upon driver start
Hi Cedric, On Tue, 2015-04-07 at 16:18 +0200, Cedric Bosdonnat wrote: Hello Lubomir On Tue, 2015-04-07 at 15:37 +0200, Lubomir Rintel wrote: /var/run may reside on a tmpfs and we fail to create the PID file if /var/run/lxc does not exist. Just mentioning the fact that this folder may not exist is OK. We have the same problem right after the libvirt installation too when creating an lxc domain. Other drivers (well, BHYVE) seem to do the same thing. Signed-off-by: Lubomir Rintel lkund...@v3.sk --- src/lxc/lxc_driver.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 245000d..4363898 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1648,6 +1648,20 @@ static int lxcStateInitialize(bool privileged, if (!(caps = virLXCDriverGetCapabilities(lxc_driver, false))) goto cleanup; +if (virFileMakePath(LXC_LOG_DIR) 0) { +virReportSystemError(errno, + _(Failed to mkdir %s), + LXC_LOG_DIR); +goto cleanup; +} Isn't that one automatically created so far? Not sure really. I didn't run into any problems with this one, just noticed that BYHIVE creates it upon start and I didn't see LXC doing that... + +if (virFileMakePath(LXC_STATE_DIR) 0) { I'ld rather use lxc_driver-config-stateDir instead LXC_STATE_DIR. I wrote a patch for that this morning and was about to email it ;) Well, I don't really know. I was thinking that maybe virPidFileWritePath() should create the path when needed, analogously to virPidFileWrite(), but creating it on start seemed a bit more consostent and less laborous. I don't feel strongly either way; feel free to send your patch instead of this one. Thanks, Lubo -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] lxc: create the required directories upon driver start
/var/run may reside on a tmpfs and we fail to create the PID file if /var/run/lxc does not exist. Other drivers (well, BHYVE) seem to do the same thing. Signed-off-by: Lubomir Rintel lkund...@v3.sk --- src/lxc/lxc_driver.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 245000d..4363898 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1648,6 +1648,20 @@ static int lxcStateInitialize(bool privileged, if (!(caps = virLXCDriverGetCapabilities(lxc_driver, false))) goto cleanup; +if (virFileMakePath(LXC_LOG_DIR) 0) { +virReportSystemError(errno, + _(Failed to mkdir %s), + LXC_LOG_DIR); +goto cleanup; +} + +if (virFileMakePath(LXC_STATE_DIR) 0) { +virReportSystemError(errno, + _(Failed to mkdir %s), + LXC_STATE_DIR); +goto cleanup; +} + /* Get all the running persistent or transient configs first */ if (virDomainObjListLoadAllConfigs(lxc_driver-domains, cfg-stateDir, -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] qemu: x86_64 is good enough for i686
virt-manager on Fedora sets up i686 hosts with /usr/bin/qemu-kvm emulator, which in turn unconditionally execs qemu-system-x86_64 querying capabilities then fails: Error launching details: invalid argument: architecture from emulator 'x86_64' doesn't match given architecture 'i686' Traceback (most recent call last): File /usr/share/virt-manager/virtManager/engine.py, line 748, in _show_vm_helper details = self._get_details_dialog(uri, vm.get_connkey()) File /usr/share/virt-manager/virtManager/engine.py, line 726, in _get_details_dialog obj = vmmDetails(conn.get_vm(connkey)) File /usr/share/virt-manager/virtManager/details.py, line 399, in __init__ self.init_details() File /usr/share/virt-manager/virtManager/details.py, line 784, in init_details domcaps = self.vm.get_domain_capabilities() File /usr/share/virt-manager/virtManager/domain.py, line 518, in get_domain_capabilities self.get_xmlobj().os.machine, self.get_xmlobj().type) File /usr/lib/python2.7/site-packages/libvirt.py, line 3492, in getDomainCapabilities if ret is None: raise libvirtError ('virConnectGetDomainCapabilities() failed', conn=self) libvirtError: invalid argument: architecture from emulator 'x86_64' doesn't match given architecture 'i686' Journal: Oct 16 21:08:26 goatlord.localdomain libvirtd[1530]: invalid argument: architecture from emulator 'x86_64' doesn't match given architecture 'i686' --- src/qemu/qemu_driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 7377320..e4b2b6c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17809,7 +17809,8 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn, arch_from_caps = virQEMUCapsGetArch(qemuCaps); -if (arch_from_caps != arch) { +if (arch_from_caps != arch + (arch_from_caps != VIR_ARCH_X86_64 || arch != VIR_ARCH_I686)) { virReportError(VIR_ERR_INVALID_ARG, _(architecture from emulator '%s' doesn't match given architecture '%s'), -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] node_device_udev: Try harder to get human readable vendor:product
The manufacurer and product from USB device itself are usually not particularly useful -- they tend to be missing, or ugly (all-uppercase, padded with spaces, etc.). Prefer what's in the usb id database and fall back to descriptors only if the device is too now to be in database. --- Before: http://v3.sk/~lkundrak/virt/old.png After: http://v3.sk/~lkundrak/virt/libvirt.png src/node_device/node_device_udev.c | 27 +-- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 0fe474d..53792f0 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -580,6 +580,7 @@ static int udevProcessUSBDevice(struct udev_device *device, { union _virNodeDevCapData *data = def-caps-data; int ret = -1; +int err; if (udevGetUintProperty(device, BUSNUM, @@ -602,10 +603,17 @@ static int udevProcessUSBDevice(struct udev_device *device, goto out; } -if (udevGetStringSysfsAttr(device, - manufacturer, - data-usb_dev.vendor_name) == PROPERTY_ERROR) { +err = udevGetStringProperty(device, +ID_VENDOR_FROM_DATABASE, +data-usb_dev.vendor_name); +if (err == PROPERTY_ERROR) goto out; +if (err == PROPERTY_MISSING) { +if (udevGetStringSysfsAttr(device, + manufacturer, + data-usb_dev.vendor_name) == PROPERTY_ERROR) { +goto out; +} } if (udevGetUintProperty(device, @@ -615,10 +623,17 @@ static int udevProcessUSBDevice(struct udev_device *device, goto out; } -if (udevGetStringSysfsAttr(device, - product, - data-usb_dev.product_name) == PROPERTY_ERROR) { +err = udevGetStringProperty(device, +ID_MODEL_FROM_DATABASE, +data-usb_dev.product_name); +if (err == PROPERTY_ERROR) goto out; +if (err == PROPERTY_MISSING) { +if (udevGetStringSysfsAttr(device, + product, + data-usb_dev.product_name) == PROPERTY_ERROR) { +goto out; +} } if (udevGenerateDeviceName(device, def, NULL) != 0) { -- 1.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list