qom-get access to kernel-irqchip property
cover qom-get access to kernel-irqchip property
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/[email protected]/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(-)
Signature · 1 line
2.19.2
RFC PATCH 1/1 hw/core: add qom getter for kernel-irqchip property
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"}
--- hw/core/machine.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
hw/core/machine.c +16 -1
@@ -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);
Signature · 1 line
2.19.2
Re: [Qemu-devel] [RFC PATCH 1/1] hw/core: add qom getter for kernel-irqchip property
Quoted 38 lines · Wainer dos Santos Moschetta
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 thekernel_irqchip_allowed,*_required, and*_splitfields 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 <[email protected]>--- hw/core/machine.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)hw/core/machine.c +2
-0@@ -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,
hw/core/machine.c static void machine_set_accel(Object *obj, const char *value, Error **errp) · line 51
Quoted 10 lines
hw/core/machine.c +10
-0+ 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,
Signature · 1 line
Peter Xu
Re: [Qemu-devel] [RFC PATCH 1/1] hw/core: add qom getter for kernel-irqchip property
Quoted 52 lines · Peter Xu
Quoted 38 lines · Wainer dos Santos Moschetta
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 thekernel_irqchip_allowed,*_required, and*_splitfields 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 <[email protected]>--- hw/core/machine.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)hw/core/machine.c +2
-0@@ -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,hw/core/machine.c static void machine_set_accel(Object *obj, const char *value, Error **errp) · line 51
Quoted 10 lines
hw/core/machine.c +10
-0+ 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,
Quoted 7 lines
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()andkvm_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).
Signature · 1 line
Eduardo