[PATCH 5/8] qemu: Support acpi-generic-initiator

Andrea Righi via Devel posted 8 patches 3 months ago
There is a newer version of this series
[PATCH 5/8] qemu: Support acpi-generic-initiator
Posted by Andrea Righi via Devel 3 months ago
Add support to the qemu driver to generate the proper command line for
the acpi-generic-initiator definitions.

Signed-off-by: Andrea Righi <arighi@nvidia.com>
---
 src/qemu/qemu_command.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 79cfe60b09..cedcb7e5a5 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -10387,6 +10387,29 @@ qemuBuildPstoreCommandLine(virCommand *cmd,
     return 0;
 }
 
+static int
+qemuBuildAcpiInitiatorCommandLine(virCommand *cmd,
+                                  const virDomainAcpiInitiatorDef *acpiinitiator,
+                                  virQEMUCaps *qemuCaps)
+{
+    g_autoptr(virJSONValue) props = NULL;
+
+    if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_ACPI_GENERIC_INITIATOR))
+        return -1;
+
+    if (virJSONValueObjectAdd(&props,
+                             "s:qom-type", "acpi-generic-initiator",
+                             "s:id", acpiinitiator->info.alias,
+                             "s:pci-dev", acpiinitiator->pciDev,
+                             "i:node", acpiinitiator->numaNode,
+                             NULL) < 0)
+        return -1;
+
+    if (qemuBuildObjectCommandlineFromJSON(cmd, props) < 0)
+        return -1;
+
+    return 0;
+}
 
 static int
 qemuBuildAsyncTeardownCommandLine(virCommand *cmd,
@@ -10741,6 +10764,11 @@ qemuBuildCommandLine(virDomainObj *vm,
         qemuBuildPstoreCommandLine(cmd, def, def->pstore, qemuCaps) < 0)
         return NULL;
 
+    for (i = 0; i < def->nacpiinitiator; i++) {
+        if (qemuBuildAcpiInitiatorCommandLine(cmd, def->acpiinitiator[i], qemuCaps) < 0)
+            return NULL;
+    }
+
     if (qemuBuildAsyncTeardownCommandLine(cmd, def, qemuCaps) < 0)
         return NULL;
 
-- 
2.49.0
Re: [PATCH 5/8] qemu: Support acpi-generic-initiator
Posted by Michal Prívozník via Devel 2 months, 2 weeks ago
On 6/8/25 22:44, Andrea Righi via Devel wrote:
> Add support to the qemu driver to generate the proper command line for
> the acpi-generic-initiator definitions.
> 
> Signed-off-by: Andrea Righi <arighi@nvidia.com>
> ---
>  src/qemu/qemu_command.c | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 79cfe60b09..cedcb7e5a5 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -10387,6 +10387,29 @@ qemuBuildPstoreCommandLine(virCommand *cmd,
>      return 0;
>  }
>  
> +static int
> +qemuBuildAcpiInitiatorCommandLine(virCommand *cmd,
> +                                  const virDomainAcpiInitiatorDef *acpiinitiator,
> +                                  virQEMUCaps *qemuCaps)
> +{
> +    g_autoptr(virJSONValue) props = NULL;
> +
> +    if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_ACPI_GENERIC_INITIATOR))
> +        return -1;
> +

No. Firstly, this doesn't belong here but into qemu_validate.c where a
new function must be invented that checks if domain def has an initiator
defined and if so then whether the capability is present.

Secondly, having this without any virReportError() will result in an
unknown error.

> +    if (virJSONValueObjectAdd(&props,
> +                             "s:qom-type", "acpi-generic-initiator",
> +                             "s:id", acpiinitiator->info.alias,
> +                             "s:pci-dev", acpiinitiator->pciDev,
> +                             "i:node", acpiinitiator->numaNode,
> +                             NULL) < 0)
> +        return -1;
> +
> +    if (qemuBuildObjectCommandlineFromJSON(cmd, props) < 0)
> +        return -1;
> +
> +    return 0;
> +}
>  
>  static int
>  qemuBuildAsyncTeardownCommandLine(virCommand *cmd,
> @@ -10741,6 +10764,11 @@ qemuBuildCommandLine(virDomainObj *vm,
>          qemuBuildPstoreCommandLine(cmd, def, def->pstore, qemuCaps) < 0)
>          return NULL;
>  
> +    for (i = 0; i < def->nacpiinitiator; i++) {
> +        if (qemuBuildAcpiInitiatorCommandLine(cmd, def->acpiinitiator[i], qemuCaps) < 0)
> +            return NULL;
> +    }
> +
>      if (qemuBuildAsyncTeardownCommandLine(cmd, def, qemuCaps) < 0)
>          return NULL;
>  

Michal