diff options
author | Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> | 2024-03-27 04:05:14 +0100 |
---|---|---|
committer | Anthony PERARD <anthony@xenproject.org> | 2024-07-01 14:57:18 +0200 |
commit | b2bbadc63c5e907bbb7a19244929ef4c028f3d01 (patch) | |
tree | 4f92d2ec61d9edecb5b0c8bd94b408cb7a1bccc1 /hw/i386 | |
parent | b6d32a06fc0984e537091cba08f2e1ed9f775d74 (diff) | |
download | qemu-b2bbadc63c5e907bbb7a19244929ef4c028f3d01.zip qemu-b2bbadc63c5e907bbb7a19244929ef4c028f3d01.tar.gz qemu-b2bbadc63c5e907bbb7a19244929ef4c028f3d01.tar.bz2 |
hw/xen: detect when running inside stubdomain
Introduce global xen_is_stubdomain variable when qemu is running inside
a stubdomain instead of dom0. This will be relevant for subsequent
patches, as few things like accessing PCI config space need to be done
differently.
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
Message-Id: <e66aa97dca5120f22e015c19710b2ff04f525720.1711506237.git-series.marmarek@invisiblethingslab.com>
Signed-off-by: Anthony PERARD <anthony@xenproject.org>
Diffstat (limited to 'hw/i386')
-rw-r--r-- | hw/i386/xen/xen-hvm.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 006d219..4f64466 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -584,6 +584,26 @@ static void xen_wakeup_notifier(Notifier *notifier, void *data) xc_set_hvm_param(xen_xc, xen_domid, HVM_PARAM_ACPI_S_STATE, 0); } +static bool xen_check_stubdomain(struct xs_handle *xsh) +{ + char *dm_path = g_strdup_printf( + "/local/domain/%d/image/device-model-domid", xen_domid); + char *val; + int32_t dm_domid; + bool is_stubdom = false; + + val = xs_read(xsh, 0, dm_path, NULL); + if (val) { + if (sscanf(val, "%d", &dm_domid) == 1) { + is_stubdom = dm_domid != 0; + } + free(val); + } + + g_free(dm_path); + return is_stubdom; +} + void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion **ram_memory) { MachineState *ms = MACHINE(pcms); @@ -596,6 +616,8 @@ void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion **ram_memory) xen_register_ioreq(state, max_cpus, &xen_memory_listener); + xen_is_stubdomain = xen_check_stubdomain(state->xenstore); + QLIST_INIT(&xen_physmap); xen_read_physmap(state); |