• Subject: [libvirt] [PATCH 0/9] RISC-V Guest Support
  • Author: Lubomir Rintel
  • Date: May 15, 2018, 10:53 a.m.
  • Patches: 8 / 9
Changeset
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
[libvirt] [PATCH 0/9] RISC-V Guest Support
Posted by Lubomir Rintel, 1 week ago
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 1/9] conf: add an option to specify a NS16550A serial port
Posted by Lubomir Rintel, 1 week ago
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 <lkundrak@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 @@
           <value>pci-serial</value>
           <value>spapr-vty</value>
           <value>pl011</value>
+          <value>ns16550a</value>
           <value>sclpconsole</value>
           <value>sclplmconsole</value>
         </choice>
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 1/9] conf: add an option to specify a NS16550A serial port
Posted by Andrea Bolognani, 5 days ago
On Tue, 2018-05-15 at 12:53 +0200, Lubomir Rintel wrote:
> 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 <lkundrak@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 @@
>            <value>pci-serial</value>
>            <value>spapr-vty</value>
>            <value>pl011</value>
> +          <value>ns16550a</value>
>            <value>sclpconsole</value>
>            <value>sclplmconsole</value>
>          </choice>

Usually, when adding new items to an existing list, we append them
rather than inserting them somewhere in the middle.

> 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",
>  );

Same here.

> 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,

And of course here.

[...]
> 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:

I'm not sure whether we want to reuse TARGET_TYPE_SYSTEM here, or
whether we need to introduce a new target type specific to RISC-V.

Last time we added target types, we asked QEMU developers for input
about the naming. I think it's a good idea to do that again.

> @@ -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;
>          }

This is wrong, as it would allow users to add ns16550a serial
consoles to aarch64 virt guests, which is clearly an incorrect
configuration. More on this later.

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/9] qemu: enable GIC only on AArch64
Posted by Lubomir Rintel, 1 week ago
Other "virt" type machines don't support it.

Signed-off-by: Lubomir Rintel <lkundrak@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
Re: [libvirt] [PATCH 2/9] qemu: enable GIC only on AArch64
Posted by Andrea Bolognani, 5 days ago
On Tue, 2018-05-15 at 12:53 +0200, Lubomir Rintel wrote:
> Other "virt" type machines don't support it.
> 
> Signed-off-by: Lubomir Rintel <lkundrak@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)) {

The check should include VIR_ARCH_ARMV7L, but that's beside the
point.

The thing is, up until now qemuDomainIsVirt() has been used to
check whether the guest uses the armv7/aarch64 virt machine type,
but now that RISC-V introduced its own virt machine type there is
a lot of potential for confusion.

IMHO the only sane way to deal with it is to rename the existing
function to qemuDomainIsArmVirt(), and introduce a new
qemuDomainIsRiscvVirt() specific to RISC-V. That will lead to a
lot of places where you have to call both, but it will also ensure
changes intended to one architecture don't end up affecting the
other.

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/9] qemu: rename qemuDomainAssignARMVirtioMMIOAddresses()
Posted by Lubomir Rintel, 1 week ago
Having a MMIO VirtIO interface is not specific to ARM. RISC-V can use it
too.

Signed-off-by: Lubomir Rintel <lkundrak@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
Re: [libvirt] [PATCH 3/9] qemu: rename qemuDomainAssignARMVirtioMMIOAddresses()
Posted by Andrea Bolognani, 5 days ago
On Tue, 2018-05-15 at 12:53 +0200, Lubomir Rintel wrote:
> Having a MMIO VirtIO interface is not specific to ARM. RISC-V can use it
> too.
> 
> Signed-off-by: Lubomir Rintel <lkundrak@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;

Agreed on this second hunk, as having a more generic name is
definitely appropriate; however, the existing function has some
Arm-specific logic that doesn't apply to RISC-V, so you should
introduce a RISC-V variant and have the generic function call
either based on the guest architecture.

-- 
Andrea Bolognani / Red Hat / Virtualization

--
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
Posted by Lubomir Rintel, 1 week ago
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 <lkundrak@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 @@
       <value>ppc64</value>
       <value>ppc64le</value>
       <value>ppcemb</value>
+      <value>riscv32</value>
+      <value>riscv64</value>
       <value>s390</value>
       <value>s390x</value>
       <value>sh4</value>
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_ARCH_ARMV7L || def->os.arch == VIR_ARCH_AARCH64) {
+        if (!(STRPREFIX(def->os.machine, "vexpress-") ||
+              qemuDomainIsVirt(def)))
+            return;
+    } else if (!ARCH_IS_RISCV(def->os.arch)) {
         return;
+    }
 
     /* We use virtio-mmio by default on mach-virt guests only if they already
      * have at least one virtio-mmio device: in all other cases, we prefer
@@ -2163,11 +2163,12 @@ static bool
 qemuDomainSupportsPCI(virDomainDefPtr def,
                       virQEMUCapsPtr qemuCaps)
 {
-    if ((def->os.arch != VIR_ARCH_ARMV7L) && (def->os.arch != VIR_ARCH_AARCH64))
-        return true;
-
-    if (STREQ(def->os.machine, "versatilepb"))
+    if (def->os.arch == VIR_ARCH_ARMV7L) {
+        if (STREQ(def->os.machine, "versatilepb"))
+            return true;
+    } else if (!(def->os.arch != VIR_ARCH_AARCH64 || ARCH_IS_RISCV(def->os.arch))) {
         return true;
+    }
 
     if (qemuDomainIsVirt(def) &&
         virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_GPEX))
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,         /* S390        32 BE http://en.wikipedia.org/wiki/S390 */
     VIR_ARCH_S390X,        /* S390        64 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.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/9] util: add RISC-V support
Posted by Andrea Bolognani, 5 days ago
On Tue, 2018-05-15 at 12:53 +0200, Lubomir Rintel wrote:
> 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 <lkundrak@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(-)

This patch breaks 'make check'. Please make sure that both 'make
check' and 'make syntax-check' pass after every single patch in
the series - it's a requirement for getting it merged.

I'll wait for a respin that addresses that before moving forward
with the review, but I'd like to make a few comments on the series
as a whole.

The way you've organized your changes could use some improvements:
for example, in this patch you're both teaching libvirt about the
RISC-V architecture and changing guest behavior, which is basically
two or more changes squashed into a single patch; moreover, I would
expect the former to happen fairly early in the series, certainly
before introducing a RISC-V specific serial device.

Squashing patches together is easier than disentangling unrelated
changes, so when in doubt always err on the side of small patches ;)

Overall, I would expect the series to be organized along the
lines of

  * preparatory work, such as creating a wrapper around
    qemuDomainAssignARMVirtioMMIOAddresses();

  * teaching libvirt about the RISC-V architecture;

  * teaching libvirt about the new serial console model (and
    potentially target type);

  * putting it all together;

  * updating the test suite.

I'm not saying you have to follow this to the letter, and more
specifically some changes to the test suite might need to happen
at the same time as you add RISC-V support, but overall it should
end up looking similar to that.

Looking forward to v2 :)

-- 
Andrea Bolognani / Red Hat / Virtualization

--
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
Posted by Lubomir Rintel, 1 week ago
Signed-off-by: Lubomir Rintel <lkundrak@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 7/9] tests/captest: check RISC-V capabilities lookup
Posted by Lubomir Rintel, 1 week ago
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 <lkundrak@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 8/9] tests/qemuxml2argvtest: test RISC-V virt machine arguments
Posted by Lubomir Rintel, 1 week ago
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 <lkundrak@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 0000000000..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 0000000000..0b6d668ebe
--- /dev/null
+++ b/tests/qemuxml2argvdata/riscv64-virt.xml
@@ -0,0 +1,34 @@
+<domain type='qemu'>
+  <name>riscv64</name>
+  <uuid>fd65fc03-8838-4c4d-9d8d-395802488790</uuid>
+  <memory unit='KiB'>2097152</memory>
+  <currentMemory unit='KiB'>2097152</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='riscv64' machine='virt'>hvm</type>
+    <kernel>/var/lib/libvirt/images/bbl</kernel>
+    <cmdline>console=ttyS0 ro root=/dev/vda</cmdline>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-riscv64</emulator>
+    <disk type='file' device='disk'>
+      <driver name='qemu' type='raw'/>
+      <source file='/var/lib/libvirt/images/stage4-disk.img'/>
+      <target dev='vda' bus='virtio'/>
+      <address type='virtio-mmio'/>
+    </disk>
+    <serial type='pty'>
+      <target type='system-serial' port='0'>
+        <model name='ns16550a'/>
+      </target>
+    </serial>
+    <console type='pty'>
+      <target type='serial' port='0'/>
+    </console>
+  </devices>
+</domain>
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 0000000000..f635862792
--- /dev/null
+++ b/tests/qemuxml2startupxmloutdata/riscv64-virt.xml
@@ -0,0 +1,37 @@
+<domain type='qemu'>
+  <name>riscv64</name>
+  <uuid>fd65fc03-8838-4c4d-9d8d-395802488790</uuid>
+  <memory unit='KiB'>2097152</memory>
+  <currentMemory unit='KiB'>2097152</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='riscv64' machine='virt'>hvm</type>
+    <kernel>/var/lib/libvirt/images/bbl</kernel>
+    <cmdline>console=ttyS0 ro root=/dev/vda</cmdline>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-riscv64</emulator>
+    <disk type='file' device='disk'>
+      <driver name='qemu' type='raw'/>
+      <source file='/var/lib/libvirt/images/stage4-disk.img'/>
+      <target dev='vda' bus='virtio'/>
+      <alias name='virtio-disk0'/>
+      <address type='virtio-mmio'/>
+    </disk>
+    <serial type='pty'>
+      <target type='system-serial' port='0'>
+        <model name='ns16550a'/>
+      </target>
+      <alias name='serial0'/>
+    </serial>
+    <console type='pty'>
+      <target type='serial' port='0'/>
+      <alias name='serial0'/>
+    </console>
+  </devices>
+</domain>
-- 
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
Posted by Lubomir Rintel, 1 week ago
Signed-off-by: Lubomir Rintel <lkundrak@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 @@
     </arch>
   </guest>
 
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='riscv32'>
+      <wordsize>32</wordsize>
+      <emulator>/usr/bin/qemu-system-riscv32</emulator>
+      <machine maxCpus='1'>spike_v1.10</machine>
+      <machine maxCpus='1'>spike_v1.9.1</machine>
+      <machine maxCpus='1'>sifive_e</machine>
+      <machine maxCpus='8'>virt</machine>
+      <machine maxCpus='1'>sifive_u</machine>
+      <domain type='qemu'/>
+    </arch>
+    <features>
+      <cpuselection/>
+      <disksnapshot default='on' toggle='no'/>
+    </features>
+  </guest>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='riscv64'>
+      <wordsize>64</wordsize>
+      <emulator>/usr/bin/qemu-system-riscv64</emulator>
+      <machine maxCpus='1'>spike_v1.10</machine>
+      <machine maxCpus='1'>spike_v1.9.1</machine>
+      <machine maxCpus='1'>sifive_e</machine>
+      <machine maxCpus='8'>virt</machine>
+      <machine maxCpus='1'>sifive_u</machine>
+      <domain type='qemu'/>
+    </arch>
+    <features>
+      <cpuselection/>
+      <disksnapshot default='on' toggle='no'/>
+    </features>
+  </guest>
+
   <guest>
     <os_type>xen</os_type>
     <arch name='i686'>
-- 
2.17.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list