All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC PATCH 0/1] qom-get access to kernel-irqchip property
@ 2018-12-24 11:52 Wainer dos Santos Moschetta
  2018-12-24 11:52 ` [Qemu-devel] [RFC PATCH 1/1] hw/core: add qom getter for " Wainer dos Santos Moschetta
  0 siblings, 1 reply; 4+ messages in thread
From: Wainer dos Santos Moschetta @ 2018-12-24 11:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: ehabkost, marcel.apfelbaum, peterx

On preparing to test Peter Xu's "q35: change defaults for kernel irqchip and
IR" patch [1] I realized that kernel-irqchip property of the Machine
Class object cannot be read via qom-get api.

Actually there isn't such as kernel_irqchip property, rather it is
a compound of kernel_irqchip_allowed, kernel_irqchip_required, and
kernel_irqchip_split. Maybe that is the reason why a getter for
kernel-irqchip was not implemented. Thus, as I don't have all the context,
I prefer to submit this a RFC implementation.

It was tested using the following code that I don't think is worth to
merge with this series, although I would like to keep it here as a
reference:

from avocado_qemu import Test

class MachineKernelIrqChip(Test):
    """
    :avocado: enable
    """
    def get_kernel_irqchip(self):
        return self.vm.command('qom-get', path='/machine',
                                          property='kernel-irqchip')
    def test_default(self):
        self.vm.add_args('-M', 'q35,accel=kvm')
        self.vm.launch()
        self.assertEqual(self.get_kernel_irqchip(), 'off')

    def test_off(self):
        self.vm.add_args('-M', 'q35,accel=kvm,kernel-irqchip=off')
        self.vm.launch()
        self.assertEqual(self.get_kernel_irqchip(), 'off')

    def test_on(self):
        self.vm.add_args('-M', 'q35,accel=kvm,kernel-irqchip=on')
        self.vm.launch()
        self.assertEqual(self.get_kernel_irqchip(), 'on')

    def test_split(self):
        self.vm.add_args('-M', 'q35,accel=kvm,kernel-irqchip=split')
        self.vm.launch()
        self.assertEqual(self.get_kernel_irqchip(), 'split')

References:
[1] https://www.mail-archive.com/qemu-devel@nongnu.org/msg582840.html

Wainer dos Santos Moschetta (1):
  hw/core: add qom getter for kernel-irqchip property

 hw/core/machine.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

-- 
2.19.2

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [RFC PATCH 1/1] hw/core: add qom getter for kernel-irqchip property
  2018-12-24 11:52 [Qemu-devel] [RFC PATCH 0/1] qom-get access to kernel-irqchip property Wainer dos Santos Moschetta
@ 2018-12-24 11:52 ` Wainer dos Santos Moschetta
  2018-12-25  5:20   ` Peter Xu
  0 siblings, 1 reply; 4+ messages in thread
From: Wainer dos Santos Moschetta @ 2018-12-24 11:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: ehabkost, marcel.apfelbaum, peterx

Allows to access the kernel-irqchip property of a Machine
Class object via QOM get method.

Before this patch the property cannot be read although it is
listed by qom-list:

qemu-system-x86_64 -M q35,accel=kvm,kernel-irqchip=split (...)
-> {"execute": "qom-list", "arguments": {"path": "/machine"}}
<- {"return": [{"name": "type", "type": "string"}, (...) , {"name": "kernel-irqchip", "type": "on|off|split"} (...)}
-> {"execute": "qom-get", "arguments": {"path": "/machine", "property": "kernel-irqchip"}}
<- {"error": {"class": "GenericError", "desc": "Insufficient permission to perform this operation"}}

It is implemented the machine_get_kernel_irqchip() method,
which evaluates the kernel_irqchip_allowed, *_required, and
*_split fields to determine the value of kernel-irqchip. Note: we
assume there is not inconsistency on the value of those fields.

Then with this change in place, it works as expected:

qemu-system-x86_64 -M q35,accel=kvm,kernel-irqchip=split (...)
-> {"execute": "qom-get", "arguments": {"path": "/machine", "property": "kernel-irqchip"}}
<- {"return": "split"}

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
---
 hw/core/machine.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index c51423b647..f61003f8f2 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -37,6 +37,21 @@ static void machine_set_accel(Object *obj, const char *value, Error **errp)
     ms->accel = g_strdup(value);
 }
 
+static void machine_get_kernel_irqchip(Object *obj, Visitor *v,
+                                       const char *name, void *opaque,
+                                       Error **errp)
+{
+    MachineState *ms = MACHINE(obj);
+    OnOffSplit mode;
+
+    if (ms->kernel_irqchip_split) {
+        mode = ON_OFF_SPLIT_SPLIT;
+    } else {
+        mode = (ms->kernel_irqchip_allowed && ms->kernel_irqchip_required) ?
+                ON_OFF_SPLIT_ON : ON_OFF_SPLIT_OFF;
+    }
+    visit_type_OnOffSplit(v, name, &mode, errp);
+}
 static void machine_set_kernel_irqchip(Object *obj, Visitor *v,
                                        const char *name, void *opaque,
                                        Error **errp)
@@ -540,7 +555,7 @@ static void machine_class_init(ObjectClass *oc, void *data)
         "Accelerator list", &error_abort);
 
     object_class_property_add(oc, "kernel-irqchip", "on|off|split",
-        NULL, machine_set_kernel_irqchip,
+        machine_get_kernel_irqchip, machine_set_kernel_irqchip,
         NULL, NULL, &error_abort);
     object_class_property_set_description(oc, "kernel-irqchip",
         "Configure KVM in-kernel irqchip", &error_abort);
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 1/1] hw/core: add qom getter for kernel-irqchip property
  2018-12-24 11:52 ` [Qemu-devel] [RFC PATCH 1/1] hw/core: add qom getter for " Wainer dos Santos Moschetta
@ 2018-12-25  5:20   ` Peter Xu
  2018-12-27 20:33     ` Eduardo Habkost
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Xu @ 2018-12-25  5:20 UTC (permalink / raw)
  To: Wainer dos Santos Moschetta
  Cc: qemu-devel, ehabkost, marcel.apfelbaum, Paolo Bonzini

On Mon, Dec 24, 2018 at 06:52:35AM -0500, Wainer dos Santos Moschetta wrote:
> Allows to access the kernel-irqchip property of a Machine
> Class object via QOM get method.
> 
> Before this patch the property cannot be read although it is
> listed by qom-list:
> 
> qemu-system-x86_64 -M q35,accel=kvm,kernel-irqchip=split (...)
> -> {"execute": "qom-list", "arguments": {"path": "/machine"}}
> <- {"return": [{"name": "type", "type": "string"}, (...) , {"name": "kernel-irqchip", "type": "on|off|split"} (...)}
> -> {"execute": "qom-get", "arguments": {"path": "/machine", "property": "kernel-irqchip"}}
> <- {"error": {"class": "GenericError", "desc": "Insufficient permission to perform this operation"}}
> 
> It is implemented the machine_get_kernel_irqchip() method,
> which evaluates the kernel_irqchip_allowed, *_required, and
> *_split fields to determine the value of kernel-irqchip. Note: we
> assume there is not inconsistency on the value of those fields.
> 
> Then with this change in place, it works as expected:
> 
> qemu-system-x86_64 -M q35,accel=kvm,kernel-irqchip=split (...)
> -> {"execute": "qom-get", "arguments": {"path": "/machine", "property": "kernel-irqchip"}}
> <- {"return": "split"}
> 
> Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
> ---
>  hw/core/machine.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index c51423b647..f61003f8f2 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -37,6 +37,21 @@ static void machine_set_accel(Object *obj, const char *value, Error **errp)
>      ms->accel = g_strdup(value);
>  }
>  
> +static void machine_get_kernel_irqchip(Object *obj, Visitor *v,
> +                                       const char *name, void *opaque,
> +                                       Error **errp)
> +{
> +    MachineState *ms = MACHINE(obj);
> +    OnOffSplit mode;
> +
> +    if (ms->kernel_irqchip_split) {
> +        mode = ON_OFF_SPLIT_SPLIT;
> +    } else {
> +        mode = (ms->kernel_irqchip_allowed && ms->kernel_irqchip_required) ?
> +                ON_OFF_SPLIT_ON : ON_OFF_SPLIT_OFF;

Hi, Wainer,

The new interface seems to be a good thing, though the implementation
might be incorrect here.  AFAIU these parameters only decide "how we
want to choose the kernel-irqchip parameter" rather than the real
result, which could depend on more (e.g., whether KVM is used).

IMHO you should simply fetch the results from kvm_irqchip_in_kernel()
and kvm_irqchip_is_split() where the real results are stored.

Regards,

-- 
Peter Xu

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 1/1] hw/core: add qom getter for kernel-irqchip property
  2018-12-25  5:20   ` Peter Xu
@ 2018-12-27 20:33     ` Eduardo Habkost
  0 siblings, 0 replies; 4+ messages in thread
From: Eduardo Habkost @ 2018-12-27 20:33 UTC (permalink / raw)
  To: Peter Xu
  Cc: Wainer dos Santos Moschetta, qemu-devel, marcel.apfelbaum, Paolo Bonzini

On Tue, Dec 25, 2018 at 01:20:05PM +0800, Peter Xu wrote:
> On Mon, Dec 24, 2018 at 06:52:35AM -0500, Wainer dos Santos Moschetta wrote:
> > Allows to access the kernel-irqchip property of a Machine
> > Class object via QOM get method.
> > 
> > Before this patch the property cannot be read although it is
> > listed by qom-list:
> > 
> > qemu-system-x86_64 -M q35,accel=kvm,kernel-irqchip=split (...)
> > -> {"execute": "qom-list", "arguments": {"path": "/machine"}}
> > <- {"return": [{"name": "type", "type": "string"}, (...) , {"name": "kernel-irqchip", "type": "on|off|split"} (...)}
> > -> {"execute": "qom-get", "arguments": {"path": "/machine", "property": "kernel-irqchip"}}
> > <- {"error": {"class": "GenericError", "desc": "Insufficient permission to perform this operation"}}
> > 
> > It is implemented the machine_get_kernel_irqchip() method,
> > which evaluates the kernel_irqchip_allowed, *_required, and
> > *_split fields to determine the value of kernel-irqchip. Note: we
> > assume there is not inconsistency on the value of those fields.
> > 
> > Then with this change in place, it works as expected:
> > 
> > qemu-system-x86_64 -M q35,accel=kvm,kernel-irqchip=split (...)
> > -> {"execute": "qom-get", "arguments": {"path": "/machine", "property": "kernel-irqchip"}}
> > <- {"return": "split"}
> > 
> > Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
> > ---
> >  hw/core/machine.c | 17 ++++++++++++++++-
> >  1 file changed, 16 insertions(+), 1 deletion(-)
> > 
> > diff --git a/hw/core/machine.c b/hw/core/machine.c
> > index c51423b647..f61003f8f2 100644
> > --- a/hw/core/machine.c
> > +++ b/hw/core/machine.c
> > @@ -37,6 +37,21 @@ static void machine_set_accel(Object *obj, const char *value, Error **errp)
> >      ms->accel = g_strdup(value);
> >  }
> >  
> > +static void machine_get_kernel_irqchip(Object *obj, Visitor *v,
> > +                                       const char *name, void *opaque,
> > +                                       Error **errp)
> > +{
> > +    MachineState *ms = MACHINE(obj);
> > +    OnOffSplit mode;
> > +
> > +    if (ms->kernel_irqchip_split) {
> > +        mode = ON_OFF_SPLIT_SPLIT;
> > +    } else {
> > +        mode = (ms->kernel_irqchip_allowed && ms->kernel_irqchip_required) ?
> > +                ON_OFF_SPLIT_ON : ON_OFF_SPLIT_OFF;
> 
> Hi, Wainer,
> 
> The new interface seems to be a good thing, though the implementation
> might be incorrect here.  AFAIU these parameters only decide "how we
> want to choose the kernel-irqchip parameter" rather than the real
> result, which could depend on more (e.g., whether KVM is used).
> 
> IMHO you should simply fetch the results from kvm_irqchip_in_kernel()
> and kvm_irqchip_is_split() where the real results are stored.

Agreed.  Knowing the actual values of kvm_irqchip_*() would be
even more useful for test code (this way we would be testing all
the KVM irqchip initialization code, not just a few lines of
property getter/seter code).

-- 
Eduardo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-12-27 20:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-24 11:52 [Qemu-devel] [RFC PATCH 0/1] qom-get access to kernel-irqchip property Wainer dos Santos Moschetta
2018-12-24 11:52 ` [Qemu-devel] [RFC PATCH 1/1] hw/core: add qom getter for " Wainer dos Santos Moschetta
2018-12-25  5:20   ` Peter Xu
2018-12-27 20:33     ` Eduardo Habkost

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.