From: Ian Campbell Date: Fri, 29 Jan 2016 12:59:56 +0000 (+0000) Subject: Port to use libxendevicemodel X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;ds=sidebyside;p=people%2Fliuw%2Flibxenctrl-split%2Fqemu-xen-traditional.git Port to use libxendevicemodel This is necessary to allow us to remove functionality from libxenctrl which is replaced by libxendevicemodel i.e. that which is only used by QEMU (trad or upstream). This does everything in one batch for simplicity, it's mostly fairly straight substitutions. The goal here (unlike with qemu-upstream) is not necessarily to abolish all uses of libxenctrl. Note that when opening the xendevicemodel handle we don't care about any attempts to restrict, since the full gamut of things needed to make that effective are only targetting QEMU upstream. Signed-off-by: Ian Campbell --- diff --git a/hw/piix_pci.c b/hw/piix_pci.c index 9c5dcf11..87782f69 100644 --- a/hw/piix_pci.c +++ b/hw/piix_pci.c @@ -412,7 +412,7 @@ static void piix3_write_config(PCIDevice *d, v = 0; v &= 0xf; if (((address+i) >= 0x60) && ((address+i) <= 0x63)) - xc_hvm_set_pci_link_route(xc_handle, domid, address + i - 0x60, v); + xendevicemodel_route_pci_intx_to_isa_irq(xen_dm, address + i - 0x60, v); } /* Hand off to default logic. */ @@ -421,6 +421,6 @@ static void piix3_write_config(PCIDevice *d, static void i440fx_set_irq(qemu_irq *pic, int irq_num, int level) { - xc_hvm_set_pci_intx_level(xc_handle, domid, 0, 0, irq_num >> 2, - irq_num & 3, level); + xendevicemodel_set_pci_intx_level(xen_dm, 0, 0, irq_num >> 2, + irq_num & 3, level); } diff --git a/hw/xen_platform.c b/hw/xen_platform.c index d282f8e7..04a1e966 100644 --- a/hw/xen_platform.c +++ b/hw/xen_platform.c @@ -207,16 +207,20 @@ static void platform_fixed_ioport_write1(void *opaque, uint32_t addr, uint32_t v { switch (addr - 0x10) { case 0: /* Platform flags */ { - hvmmem_type_t mem_type = (val & PFFLAG_ROM_LOCK) ? - HVMMEM_ram_ro : HVMMEM_ram_rw; - if (xc_hvm_set_mem_type(xc_handle, domid, mem_type, 0xc0, 0x40)) + int rc; + + if (val & PFFLAG_ROM_LOCK) + rc = xendevicemodel_make_ram_region_ro(xen_dm, 0xc0, 0x40); + else + rc = xendevicemodel_make_ram_region_rw(xen_dm, 0xc0, 0x40); + if (rc) fprintf(logfile,"platform_fixed_ioport: unable to change ro/rw " "state of ROM memory area!\n"); else { platform_flags = val & PFFLAG_ROM_LOCK; fprintf(logfile,"platform_fixed_ioport: changed ro/rw " "state of ROM memory area. now is %s state.\n", - (mem_type == HVMMEM_ram_ro ? "ro":"rw")); + (val & PFFLAG_ROM_LOCK ? "ro":"rw")); } break; } diff --git a/i386-dm/helper2.c b/i386-dm/helper2.c index 8c61a243..a184bff0 100644 --- a/i386-dm/helper2.c +++ b/i386-dm/helper2.c @@ -85,6 +85,7 @@ int vcpus = 1; uint32_t vcpu_avail[(HVM_MAX_VCPUS + 31)/32] = {0}; xc_interface *xc_handle; +xendevicemodel_handle *xen_dm = NULL; char domain_name[64] = "Xen-no-name"; diff --git a/i386-dm/i8259.c b/i386-dm/i8259.c index 40bbee0b..be41cbcd 100644 --- a/i386-dm/i8259.c +++ b/i386-dm/i8259.c @@ -30,7 +30,7 @@ #include static void i8259_set_irq(void *opaque, int irq, int level) { - xc_hvm_set_isa_irq_level(xc_handle, domid, irq, level); + xendevicemodel_set_isa_irq_level(xen_dm, irq, level); } qemu_irq *i8259_init(qemu_irq parent_irq) diff --git a/vl.c b/vl.c index c864e7de..3b8c2626 100644 --- a/vl.c +++ b/vl.c @@ -5830,6 +5830,9 @@ int main(int argc, char **argv, char **envp) dma_helper_init(); xc_handle = xc_interface_open(0,0,0); /* fixme check errors */ + /* We don't care about restricting this handle */ + xen_dm = xendevicemodel_open(0, domid, 0, NULL); + xenstore_init(); if (!strcmp(machine->name, "xenfv")) { #ifdef CONFIG_STUBDOM diff --git a/xen-config-host.h b/xen-config-host.h index 3a020215..3de16e4e 100644 --- a/xen-config-host.h +++ b/xen-config-host.h @@ -21,6 +21,7 @@ extern int domid, domid_backend; #if defined(CONFIG_BLKTAP1) && !defined(CONFIG_STUBDOM) && !defined(__NetBSD__) #include "blktaplib.h" #endif +#include "xendevicemodel.h" #define BIOS_SIZE ((256 + 64) * 1024) @@ -29,6 +30,8 @@ extern int domid, domid_backend; void main_loop_prepare(void); extern xc_interface *xc_handle; +extern xendevicemodel_handle *xen_dm; + extern int xen_pause_requested; extern int vcpus; extern uint32_t vcpu_avail[]; diff --git a/xen-hooks.mak b/xen-hooks.mak index c1ea4be5..29d09c7f 100644 --- a/xen-hooks.mak +++ b/xen-hooks.mak @@ -1,6 +1,7 @@ CPPFLAGS+= -I$(XEN_ROOT)/tools/libs/toollog/include CPPFLAGS+= -I$(XEN_ROOT)/tools/libs/evtchn/include CPPFLAGS+= -I$(XEN_ROOT)/tools/libs/gnttab/include +CPPFLAGS+= -I$(XEN_ROOT)/tools/libs/devicemodel/include CPPFLAGS+= -DXC_WANT_COMPAT_MAP_FOREIGN_API CPPFLAGS+= -I$(XEN_ROOT)/tools/libxc/include CPPFLAGS+= -I$(XEN_ROOT)/tools/xenstore/include @@ -23,6 +24,7 @@ CFLAGS += $(CMDLINE_CFLAGS) LIBS += -L$(XEN_ROOT)/tools/libs/evtchn -lxenevtchn LIBS += -L$(XEN_ROOT)/tools/libs/gnttab -lxengnttab +LIBS += -L$(XEN_ROOT)/tools/libs/devicemodel -lxendevicemodel LIBS += -L$(XEN_ROOT)/tools/libxc -lxenctrl -lxenguest LIBS += -L$(XEN_ROOT)/tools/xenstore -lxenstore LIBS += -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/toollog