[Qemu-devel] [PATCH] qemu-config: Use QEMU instead of Qemu
This new 'Qemu' was recently added. Replace it by the official all upper case 'QEMU'. Signed-off-by: Stefan Weil --- qemu-config.h |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu-config.h b/qemu-config.h index e9f2ef4..12ddf3e 100644 --- a/qemu-config.h +++ b/qemu-config.h @@ -19,7 +19,7 @@ int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname); int qemu_read_config_file(const char *filename); -/* Read default Qemu config files +/* Read default QEMU config files */ int qemu_read_default_config_files(bool userconfig); -- 1.7.10
Re: [Qemu-devel] [libvirt] [PATCH 2/2] qemu_agent: Wait for events instead of agent response
On 15.06.2012 19:16, Eric Blake wrote: > On 06/15/2012 10:10 AM, Michal Privoznik wrote: >> With latest changes to qemu-ga success on some commands is not reported >> anymore, e.g. guest-shutdown or guest-suspend-*. However, errors are >> still being reported. Therefore, we need to find different source of >> indication if operation was successful. Events. >> --- >> src/qemu/qemu_agent.c | 49 >> ++ >> src/qemu/qemu_agent.h |9 >> src/qemu/qemu_process.c |7 ++ >> 3 files changed, 60 insertions(+), 5 deletions(-) >> > >> @@ -1238,6 +1257,24 @@ error: >> return NULL; >> } >> >> +void qemuAgentNotifyEvent(qemuAgentPtr mon, >> + qemuAgentEvent event) >> +{ >> +VIR_DEBUG("mon=%p event=%d", mon, event); >> +if (mon->await_event == event) { >> +VIR_DEBUG("Wakening up a tragedian"); > > s/Wakening/Waking/ > > ACK. > > Fixed and pushed. Thanks. Michal
Re: [Qemu-devel] [PATCH v2 35/41] postcopy: introduce helper functions for postcopy
On Thu, Jun 14, 2012 at 11:34:09PM +0200, Juan Quintela wrote: > Isaku Yamahata wrote: > > +//#define DEBUG_UMEM > > +#ifdef DEBUG_UMEM > > +#include > > +#define DPRINTF(format, ...)\ > > +do {\ > > +printf("%d:%ld %s:%d "format, getpid(), syscall(SYS_gettid),\ > > + __func__, __LINE__, ## __VA_ARGS__); \ > > +} while (0) > > This should be in a header file that is linux specific? And (at least > on my systems) gettid is already defined on glibc. I'll remove getpid/gettid. It was just for debugging in early phase. They are not necessary any more. > > +#else > > +#define DPRINTF(format, ...)do { } while (0) > > +#endif > > > > + > > +#define DEV_UMEM"/dev/umem" > > + > > +UMem *umem_new(void *hostp, size_t size) > > +{ > > +struct umem_init uinit = { > > +.size = size, > > +}; > > +UMem *umem; > > + > > +assert((size % getpagesize()) == 0); > > +umem = g_new(UMem, 1); > > +umem->fd = open(DEV_UMEM, O_RDWR); > > +if (umem->fd < 0) { > > +perror("can't open "DEV_UMEM); > > +abort(); > > Can we return one error insntead of abort? the same for the rest of the > file aborts. Ok. > > +size_t umem_pages_size(uint64_t nr) > > +{ > > +return sizeof(struct umem_pages) + nr * sizeof(uint64_t); > > Can we make sure that the pgoffs field is aligned? I know that as it is > now it is aligned, but better to be sure? It is already done by gcc extension, zero length array. > > +} > > + > > +static void umem_write_cmd(int fd, uint8_t cmd) > > +{ > > +DPRINTF("write cmd %c\n", cmd); > > + > > +for (;;) { > > +ssize_t ret = write(fd, &cmd, 1); > > +if (ret == -1) { > > +if (errno == EINTR) { > > +continue; > > +} else if (errno == EPIPE) { > > +perror("pipe"); > > +DPRINTF("write cmd %c %zd %d: pipe is closed\n", > > +cmd, ret, errno); > > +break; > > +} > > > Grr, we don't have a function that writes does a "safe_write". The most > similar thing in qemu looks to be send_all(). So we should introduce something like qemu_safe_write/read? > > + > > +perror("pipe"); > > Can we make a different perror() message than previous error? > > > +DPRINTF("write cmd %c %zd %d\n", cmd, ret, errno); > > +abort(); > > +} > > + > > +break; > > +} > > +} > > + > > +static void umem_read_cmd(int fd, uint8_t expect) > > +{ > > +uint8_t cmd; > > +for (;;) { > > +ssize_t ret = read(fd, &cmd, 1); > > +if (ret == -1) { > > +if (errno == EINTR) { > > +continue; > > +} > > +perror("pipe"); > > +DPRINTF("read error cmd %c %zd %d\n", cmd, ret, errno); > > +abort(); > > +} > > + > > +if (ret == 0) { > > +DPRINTF("read cmd %c %zd: pipe is closed\n", cmd, ret); > > +abort(); > > +} > > + > > +break; > > +} > > + > > +DPRINTF("read cmd %c\n", cmd); > > +if (cmd != expect) { > > +DPRINTF("cmd %c expect %d\n", cmd, expect); > > +abort(); > > Ouch. If we receive garbage, we just exit? > > I really think that we should implement error handling. > > > +} > > +} > > + > > +struct umem_pages *umem_recv_pages(QEMUFile *f, int *offset) > > +{ > > +int ret; > > +uint64_t nr; > > +size_t size; > > +struct umem_pages *pages; > > + > > +ret = qemu_peek_buffer(f, (uint8_t*)&nr, sizeof(nr), *offset); > > +*offset += sizeof(nr); > > +DPRINTF("ret %d nr %ld\n", ret, nr); > > +if (ret != sizeof(nr) || nr == 0) { > > +return NULL; > > +} > > + > > +size = umem_pages_size(nr); > > +pages = g_malloc(size); > > Just thinking about this. Couldn't we just decide on a "big enough" > buffer, and never send anything bigger than that? That would remove the > need to have to malloc()/free() a buffer for each reception? Will try to address it. > > +/* qemu side handler */ > > +struct umem_pages *umem_qemu_trigger_page_fault(QEMUFile *from_umemd, > > +int *offset) > > +{ > > +uint64_t i; > > +int page_shift = ffs(getpagesize()) - 1; > > +struct umem_pages *pages = umem_recv_pages(from_umemd, offset); > > +if (pages == NULL) { > > +return NULL; > > +} > > + > > +for (i = 0; i < pages->nr; i++) { > > +ram_addr_t addr = pages->pgoffs[i] << page_shift; > > + > > +/* make pages present by forcibly triggering page fault. */ > > +volatile uint8_t *ram = qemu_get_ram_ptr(addr); > > +uint8_t dummy_read = ram[0]; > > +(void)dummy_read; /* suppress unused variable warning */ > > +
[Qemu-devel] [PATCH v1 0/3] QOMify AXI stream for Xilinx AXI ethernet/DMA
Next revision of the series for AXI-stream, rebased on anthonys refactoring of the Interface system. Anthonys patch is already on the mailing list, but I have included it form completeness. There was an issue with combining links and interface that is resolved and discussed in the Blurb for P3. P2 is all the device-land stuff. Anthony Liguori (1): qom: reimplement Interfaces Peter A. G. Crosthwaite (2): xilinx_axi*: Re-implemented interconnect qom: Converged dynamic cast for interfaces & objs hw/Makefile.objs |1 + hw/petalogix_ml605_mmu.c | 24 +++-- hw/stream.c | 23 + hw/stream.h | 31 ++ hw/xilinx.h | 22 ++--- hw/xilinx_axidma.c | 74 --- hw/xilinx_axidma.h | 39 hw/xilinx_axienet.c | 32 --- include/qemu/object.h| 46 ++--- qom/object.c | 236 +++--- 10 files changed, 268 insertions(+), 260 deletions(-) create mode 100644 hw/stream.c create mode 100644 hw/stream.h delete mode 100644 hw/xilinx_axidma.h -- 1.7.3.2
[Qemu-devel] [PATCH v1 1/3] qom: reimplement Interfaces
From: Anthony Liguori The current implementation of Interfaces is poorly designed. Each interface that an object implements end up being an object that's tracked by the implementing object. There's all sorts of gymnastics to deal with casting between these objects. By an interface shouldn't be associated with an Object. Interfaces are global to a class. This patch moves all Interface knowledge to ObjectClass eliminating the relationship between Object and Interfaces. Interfaces are now abstract (as they should be) but this is okay. Interfaces essentially act as additional parents for the classes and are treated as such. With this new implementation, we should fully support derived interfaces including reimplementing an inherited interface. Signed-off-by: Anthony Liguori --- include/qemu/object.h | 64 +++--- qom/object.c | 231 +++- 2 files changed, 160 insertions(+), 135 deletions(-) diff --git a/include/qemu/object.h b/include/qemu/object.h index d93b772..72cb290 100644 --- a/include/qemu/object.h +++ b/include/qemu/object.h @@ -239,6 +239,7 @@ struct ObjectClass { /*< private >*/ Type type; +GSList *interfaces; }; /** @@ -260,7 +261,6 @@ struct Object { /*< private >*/ ObjectClass *class; -GSList *interfaces; QTAILQ_HEAD(, ObjectProperty) properties; uint32_t ref; Object *parent; @@ -381,6 +381,17 @@ struct TypeInfo OBJECT_CLASS_CHECK(class, object_get_class(OBJECT(obj)), name) /** + * InterfaceInfo: + * @type: The name of the interface. + * + * The information associated with an interface. + */ +struct InterfaceInfo +{ +const char *type; +}; + +/** * InterfaceClass: * @parent_class: the base class * @@ -390,26 +401,31 @@ struct TypeInfo struct InterfaceClass { ObjectClass parent_class; +/*< private >*/ +ObjectClass *concrete_class; }; +#define TYPE_INTERFACE "interface" + /** - * InterfaceInfo: - * @type: The name of the interface. - * @interface_initfn: This method is called during class initialization and is - * used to initialize an interface associated with a class. This function - * should initialize any default virtual functions for a class and/or override - * virtual functions in a parent class. + * INTERFACE_CLASS: + * @klass: class to cast from * - * The information associated with an interface. + * Returns: An #InterfaceClass or raise an error if cast is invalid */ -struct InterfaceInfo -{ -const char *type; +#define INTERFACE_CLASS(klass) \ +OBJECT_CLASS_CHECK(InterfaceClass, klass, TYPE_INTERFACE) -void (*interface_initfn)(ObjectClass *class, void *data); -}; - -#define TYPE_INTERFACE "interface" +/** + * INTERFACE_CHECK: + * @interface: the type to return + * @obj: the object to convert to an interface + * @name: the interface type name + * + * Returns: @obj casted to @interface if cast is valid, otherwise raise error. + */ +#define INTERFACE_CHECK(interface, obj, name) \ +((interface *)interface_dynamic_cast_assert(OBJECT((obj)), (name))) /** * object_new: @@ -548,6 +564,24 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *klass, const char *typename); /** + * interface_dynamic_cast_assert: + * @obj: the object to cast to an interface type + * @typename: the type name of the interface + * + * Returns: @obj if @obj implements @typename, otherwise raise an error + */ +Object *interface_dynamic_cast_assert(Object *obj, const char *typename); + +/** + * interface_dynamic_cast_assert: + * @obj: the object to cast to an interface type + * @typename: the type name of the interface + * + * Returns: @obj if @obj implements @typename, otherwise %NULL + */ +Object *interface_dynamic_cast(Object *obj, const char *typename); + +/** * object_class_get_name: * @klass: The class to obtain the QOM typename for. * diff --git a/qom/object.c b/qom/object.c index 6f839ad..aa26693 100644 --- a/qom/object.c +++ b/qom/object.c @@ -31,9 +31,7 @@ typedef struct TypeImpl TypeImpl; struct InterfaceImpl { -const char *parent; -void (*interface_initfn)(ObjectClass *class, void *data); -TypeImpl *type; +const char *typename; }; struct TypeImpl @@ -63,14 +61,6 @@ struct TypeImpl InterfaceImpl interfaces[MAX_INTERFACES]; }; -typedef struct Interface -{ -Object parent; -Object *obj; -} Interface; - -#define INTERFACE(obj) OBJECT_CHECK(Interface, obj, TYPE_INTERFACE) - static Type type_interface; static GHashTable *type_table_get(void) @@ -97,6 +87,7 @@ static TypeImpl *type_table_lookup(const char *name) TypeImpl *type_register(const TypeInfo *info) { TypeImpl *ti = g_malloc0(sizeof(*ti)); +int i; g_assert(info->name != NULL); @@ -120,15 +111,10 @@ TypeImpl *type_register(const TypeInfo *info) ti->abstract = info->abstract; -if (info->interfaces) { -int i; - -for (i = 0; info->inter
[Qemu-devel] [PATCH v1 3/3] qom: Converged dynamic cast for interfaces & objs
Interfaces and Object for some reason have seperate code paths for dynamic casting. AFAICT, Anthonys new interface specific cast is a functional superset of the object cast, so this patch renames the interface cast to object cast and blows away the original object cast. Anyone want to shed any light on why the casts need to be different? The problem (and the reason for this patch) is its not always possible for user of interface to control how their object are going to be casted. Where this broke down big-time is with links. The link setter code path explictly uses object_dynamic_cast(), when link are set, which pretty much makes linking to interfaces impossible. So either: 1: This patch 2: Explictly test objects/classes for interfacage in the link setting code 3: Ban linking to interfaces Signed-off-by: Peter A. G. Crosthwaite --- include/qemu/object.h | 20 +--- qom/object.c | 49 + 2 files changed, 10 insertions(+), 59 deletions(-) diff --git a/include/qemu/object.h b/include/qemu/object.h index 72cb290..a8916ce 100644 --- a/include/qemu/object.h +++ b/include/qemu/object.h @@ -425,7 +425,7 @@ struct InterfaceClass * Returns: @obj casted to @interface if cast is valid, otherwise raise error. */ #define INTERFACE_CHECK(interface, obj, name) \ -((interface *)interface_dynamic_cast_assert(OBJECT((obj)), (name))) +((interface *)object_dynamic_cast_assert(OBJECT((obj)), (name))) /** * object_new: @@ -564,24 +564,6 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *klass, const char *typename); /** - * interface_dynamic_cast_assert: - * @obj: the object to cast to an interface type - * @typename: the type name of the interface - * - * Returns: @obj if @obj implements @typename, otherwise raise an error - */ -Object *interface_dynamic_cast_assert(Object *obj, const char *typename); - -/** - * interface_dynamic_cast_assert: - * @obj: the object to cast to an interface type - * @typename: the type name of the interface - * - * Returns: @obj if @obj implements @typename, otherwise %NULL - */ -Object *interface_dynamic_cast(Object *obj, const char *typename); - -/** * object_class_get_name: * @klass: The class to obtain the QOM typename for. * diff --git a/qom/object.c b/qom/object.c index aa26693..7574666 100644 --- a/qom/object.c +++ b/qom/object.c @@ -405,24 +405,6 @@ static bool object_is_type(Object *obj, TypeImpl *target_type) return !target_type || type_is_ancestor(obj->class->type, target_type); } -Object *object_dynamic_cast(Object *obj, const char *typename) -{ -TypeImpl *target_type = type_get_by_name(typename); - -/* Check if typename is a direct ancestor. Special-case TYPE_OBJECT, - * we want to go back from interfaces to the parent. -*/ -if (target_type && object_is_type(obj, target_type)) { -return obj; -} - -if (!target_type) { -return obj; -} - -return NULL; -} - static void register_types(void) { static TypeInfo interface_info = { @@ -436,6 +418,15 @@ static void register_types(void) type_init(register_types) +Object *object_dynamic_cast(Object *obj, const char *typename) +{ +if (object_class_dynamic_cast(object_get_class(obj), typename)) { +return obj; +} + +return NULL; +} + Object *object_dynamic_cast_assert(Object *obj, const char *typename) { Object *inst; @@ -496,28 +487,6 @@ ObjectClass *object_class_dynamic_cast_assert(ObjectClass *class, return ret; } -Object *interface_dynamic_cast(Object *obj, const char *typename) -{ -if (object_class_dynamic_cast(object_get_class(obj), typename)) { -return obj; -} - -return NULL; -} - -Object *interface_dynamic_cast_assert(Object *obj, const char *typename) -{ -Object *ret = interface_dynamic_cast(obj, typename); - -if (!ret) { -fprintf(stderr, "Object %p is not an instance of type %s\n", -obj, typename); -abort(); -} - -return ret; -} - const char *object_get_typename(Object *obj) { return obj->class->type->name; -- 1.7.3.2
[Qemu-devel] [PATCH v1 2/3] xilinx_axi*: Re-implemented interconnect
Re-implemented the interconnect between the Xilinx AXI ethernet and DMA controllers. A QOM interface "stream" is created, for the two stream interfaces. As per Edgars request, this is designed to be more generic than AXI-stream, so in the future we may see more clients of this interface beyond AXI stream. This is based primarily on Paolos original refactoring of the interconnect. Signed-off-by: Paolo Bonzini Signed-off-by: Peter A.G. Crosthwaite --- changed since v0: This patch is the combination of P2,P3,P7 & P8 of v0 renamed all axi_stream_foo to stream_foo (Edgar review) hw/Makefile.objs |1 + hw/petalogix_ml605_mmu.c | 24 +-- hw/stream.c | 23 ++ hw/stream.h | 31 +++ hw/xilinx.h | 22 + hw/xilinx_axidma.c | 74 + hw/xilinx_axidma.h | 39 hw/xilinx_axienet.c | 32 --- 8 files changed, 139 insertions(+), 107 deletions(-) create mode 100644 hw/stream.c create mode 100644 hw/stream.h delete mode 100644 hw/xilinx_axidma.h diff --git a/hw/Makefile.objs b/hw/Makefile.objs index 3d77259..5e2f5be 100644 --- a/hw/Makefile.objs +++ b/hw/Makefile.objs @@ -65,6 +65,7 @@ hw-obj-$(CONFIG_XILINX) += xilinx_timer.o hw-obj-$(CONFIG_XILINX) += xilinx_uartlite.o hw-obj-$(CONFIG_XILINX_AXI) += xilinx_axidma.o hw-obj-$(CONFIG_XILINX_AXI) += xilinx_axienet.o +hw-obj-$(CONFIG_XILINX_AXI) += stream.o # PCI watchdog devices hw-obj-$(CONFIG_PCI) += wdt_i6300esb.o diff --git a/hw/petalogix_ml605_mmu.c b/hw/petalogix_ml605_mmu.c index 6a7d0c0..dced648 100644 --- a/hw/petalogix_ml605_mmu.c +++ b/hw/petalogix_ml605_mmu.c @@ -39,7 +39,8 @@ #include "microblaze_boot.h" #include "microblaze_pic_cpu.h" -#include "xilinx_axidma.h" + +#include "stream.h" #define LMB_BRAM_SIZE (128 * 1024) #define FLASH_SIZE (32 * 1024 * 1024) @@ -76,7 +77,7 @@ petalogix_ml605_init(ram_addr_t ram_size, const char *initrd_filename, const char *cpu_model) { MemoryRegion *address_space_mem = get_system_memory(); -DeviceState *dev; +DeviceState *dev, *dma, *eth0; MicroBlazeCPU *cpu; CPUMBState *env; DriveInfo *dinfo; @@ -125,15 +126,18 @@ petalogix_ml605_init(ram_addr_t ram_size, /* 2 timers at irq 2 @ 100 Mhz. */ xilinx_timer_create(TIMER_BASEADDR, irq[2], 0, 100 * 100); -/* axi ethernet and dma initialization. TODO: Dynamically connect them. */ -{ -static struct XilinxDMAConnection dmach; +/* axi ethernet and dma initialization. */ +dma = qdev_create(NULL, "xlnx.axi-dma"); -xilinx_axiethernet_create(&dmach, &nd_table[0], 0x8278, - irq[3], 0x1000, 0x1000); -xilinx_axiethernetdma_create(&dmach, 0x8460, - irq[1], irq[0], 100 * 100); -} +/* FIXME: attach to the sysbus instead */ +object_property_add_child(container_get(qdev_get_machine(), "/unattached"), + "xilinx-dma", OBJECT(dma), NULL); + +eth0 = xilinx_axiethernet_create(&nd_table[0], STREAM_SLAVE(dma), + 0x8278, irq[3], 0x1000, 0x1000); + +xilinx_axiethernetdma_init(dma, STREAM_SLAVE(eth0), + 0x8460, irq[1], irq[0], 100 * 100); microblaze_load_kernel(cpu, ddr_base, ram_size, BINARY_DEVICE_TREE_FILE, machine_cpu_reset); diff --git a/hw/stream.c b/hw/stream.c new file mode 100644 index 000..001e2bd --- /dev/null +++ b/hw/stream.c @@ -0,0 +1,23 @@ +#include "stream.h" + +void +axi_stream_push(StreamSlave *sink, uint8_t *buf, size_t len, uint32_t *app) +{ +StreamSlaveClass *k = STREAM_SLAVE_GET_CLASS(sink); + +k->push(sink, buf, len, app); +} + +static TypeInfo axi_stream_slave_info = { +.name = TYPE_STREAM_SLAVE, +.parent= TYPE_INTERFACE, +.class_size = sizeof(StreamSlaveClass), +}; + + +static void axi_stream_slave_register_types(void) +{ +type_register_static(&axi_stream_slave_info); +} + +type_init(axi_stream_slave_register_types) diff --git a/hw/stream.h b/hw/stream.h new file mode 100644 index 000..b7f3b3e --- /dev/null +++ b/hw/stream.h @@ -0,0 +1,31 @@ +#ifndef STREAM_H +#define STREAM_H 1 + +#include "qemu-common.h" +#include "qemu/object.h" + +/* AXI stream slave. Used until qdev provides a generic way. */ +#define TYPE_STREAM_SLAVE "stream-slave" + +#define STREAM_SLAVE_CLASS(klass) \ + OBJECT_CLASS_CHECK(StreamSlaveClass, (klass), TYPE_STREAM_SLAVE) +#define STREAM_SLAVE_GET_CLASS(obj) \ +OBJECT_GET_CLASS(StreamSlaveClass, (obj), TYPE_STREAM_SLAVE) +#define STREAM_SLAVE(obj) \ + INTERFACE_CHECK(StreamSlave, (obj), TYPE_STREAM_SLAVE) + +typedef struct StreamSlave { +Object Parent; +} StreamSlave; +
Re: [Qemu-devel] [PATCH 3/3] qom: add unit test for Interfaces
On Thu, Jun 14, 2012 at 6:55 AM, Anthony Liguori wrote: > Signed-off-by: Anthony Liguori Reviewed-by: Peter A.G. Crosthwaite > --- > tests/Makefile | 5 +- > tests/test-object.c | 222 > +++ > 2 files changed, 226 insertions(+), 1 deletions(-) > create mode 100644 tests/test-object.c > > diff --git a/tests/Makefile b/tests/Makefile > index d66ab19..d1f979d 100644 > --- a/tests/Makefile > +++ b/tests/Makefile > @@ -14,6 +14,7 @@ check-unit-y += tests/test-string-input-visitor$(EXESUF) > check-unit-y += tests/test-string-output-visitor$(EXESUF) > check-unit-y += tests/test-coroutine$(EXESUF) > check-unit-y += tests/test-visitor-serialization$(EXESUF) > +check-unit-y += tests/test-object$(EXESUF) > > check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh > > @@ -32,7 +33,8 @@ test-obj-y = tests/check-qint.o tests/check-qstring.o > tests/check-qdict.o \ > tests/test-coroutine.o tests/test-string-output-visitor.o \ > tests/test-string-input-visitor.o tests/test-qmp-output-visitor.o \ > tests/test-qmp-input-visitor.o tests/test-qmp-input-strict.o \ > - tests/test-qmp-commands.o tests/test-visitor-serialization.o > + tests/test-qmp-commands.o tests/test-visitor-serialization.o \ > + tests/test-object.o > > test-qapi-obj-y = $(qobject-obj-y) $(qapi-obj-y) $(tools-obj-y) > test-qapi-obj-y += tests/test-qapi-visit.o tests/test-qapi-types.o > @@ -66,6 +68,7 @@ tests/test-qmp-input-visitor$(EXESUF): > tests/test-qmp-input-visitor.o $(test-qap > tests/test-qmp-input-strict$(EXESUF): tests/test-qmp-input-strict.o > $(test-qapi-obj-y) > tests/test-qmp-commands$(EXESUF): tests/test-qmp-commands.o > tests/test-qmp-marshal.o $(test-qapi-obj-y) > tests/test-visitor-serialization$(EXESUF): > tests/test-visitor-serialization.o $(test-qapi-obj-y) > +tests/test-object$(EXESUF): tests/test-object.o $(qom-obj-y) > $(test-qapi-obj-y) > > tests/rtc-test$(EXESUF): tests/rtc-test.o $(trace-obj-y) > tests/m48t59-test$(EXESUF): tests/m48t59-test.o $(trace-obj-y) > diff --git a/tests/test-object.c b/tests/test-object.c > new file mode 100644 > index 000..9f41da0 > --- /dev/null > +++ b/tests/test-object.c > @@ -0,0 +1,222 @@ > +/* > + * QEMU Object Model unit test > + * > + * Copyright IBM, Corp. 2012 > + * > + * Authors: > + * Anthony Liguori > + * > + * This work is licensed under the terms of the GNU GPL, version 2 or later. > + * See the COPYING file in the top-level directory. > + * > + */ > +#include "qemu/object.h" > +#include "module.h" > + > +#define TYPE_HERBIVORE "herbivore" > + > +#define HERBIVORE_CLASS(klass) \ > + OBJECT_CLASS_CHECK(HerbivoreClass, (klass), TYPE_HERBIVORE) > +#define HERBIVORE_GET_CLASS(obj) \ > + OBJECT_GET_CLASS(HerbivoreClass, (obj), TYPE_HERBIVORE) > +#define HERBIVORE(obj) \ > + INTERFACE_CHECK(Herbivore, (obj), TYPE_HERBIVORE) > + > +typedef struct Herbivore > +{ > + Object obj; > +} Herbivore; All this is doing is saying Herbivores are Objects right? A user cant add anything to this struct given that interfaces are stateless so could this be simplified to typedef Object Herbivore; ? > + > +typedef struct HerbivoreClass > +{ > + InterfaceClass parent; > + > + void (*feed_greens)(Herbivore *obj); > +} HerbivoreClass; > + > +static void herbivore_feed_greens(Herbivore *herbie) > +{ > + HerbivoreClass *k = HERBIVORE_GET_CLASS(herbie); > + > + k->feed_greens(herbie); > +} > + > +static TypeInfo herbivore_info = { > + .name = TYPE_HERBIVORE, > + .parent = TYPE_INTERFACE, > + .class_size = sizeof(HerbivoreClass), > +}; > + > +#define TYPE_CARNIVORE "carnivore" > +#define CARNIVORE_CLASS(klass) \ > + OBJECT_CLASS_CHECK(CarnivoreClass, (klass), TYPE_CARNIVORE) > +#define CARNIVORE_GET_CLASS(obj) \ > + OBJECT_GET_CLASS(CarnivoreClass, (obj), TYPE_CARNIVORE) > +#define CARNIVORE(obj) \ > + INTERFACE_CHECK(Carnivore, (obj), TYPE_CARNIVORE) > + > +typedef struct Carnivore > +{ > + Object parent; > +} Carnivore; > + > +typedef struct CarnivoreClass > +{ > + InterfaceClass parent; > + > + void (*feed_bugs)(Carnivore *obj); > +} CarnivoreClass; > + > +static void carnivore_feed_bugs(Carnivore *carnie) > +{ > + CarnivoreClass *k = CARNIVORE_GET_CLASS(carnie); > + > + k->feed_bugs(carnie); > +} > + > +static TypeInfo carnivore_info = { > + .name = TYPE_CARNIVORE, > + .parent = TYPE_INTERFACE, > + .class_size = sizeof(CarnivoreClass), > +}; > + > +#define TYPE_REPTILE "reptile" > +#define REPTILE(obj) OBJECT_CHECK(Reptile, (obj), TYPE_REPTILE) > + > +typedef struct Reptile > +{ > + Object parent; > +} Reptile; > + > +static TypeInfo reptile_info = { > + .name = TYPE_REPTILE, > + .instance_size = sizeof(Reptile), > + .abstract = true, > + .class_size = sizeof(ObjectClass), > +}; > + > +#define TYPE_LIZARD "lizard" > +#define LIZARD(obj) OBJECT_CHECK(Lizard, (obj), TYPE_LIZARD) > + > +typedef struct Lizar
Re: [Qemu-devel] [PATCH 2/3] qom: reimplement Interfaces
On Wed, 2012-06-13 at 15:55 -0500, Anthony Liguori wrote: > The current implementation of Interfaces is poorly designed. Each interface > that an object implements end up being an object that's tracked by the "ends" > implementing object. There's all sorts of gymnastics to deal with casting > between these objects. > > By an interface shouldn't be associated with an Object. Interfaces are global "But" ? > to a class. This patch moves all Interface knowledge to ObjectClass > eliminating > the relationship between Object and Interfaces. > > Interfaces are now abstract (as they should be) but this is okay. Interfaces > essentially act as additional parents for the classes and are treated as such. > > With this new implementation, we should fully support derived interfaces > including reimplementing an inherited interface. > > Signed-off-by: Anthony Liguori > --- > include/qemu/object.h | 64 +++--- > qom/object.c | 231 +++- > 2 files changed, 160 insertions(+), 135 deletions(-) > > diff --git a/include/qemu/object.h b/include/qemu/object.h > index d93b772..72cb290 100644 > --- a/include/qemu/object.h > +++ b/include/qemu/object.h > @@ -239,6 +239,7 @@ struct ObjectClass > { > /*< private >*/ > Type type; > +GSList *interfaces; > }; > > /** > @@ -260,7 +261,6 @@ struct Object > { > /*< private >*/ > ObjectClass *class; > -GSList *interfaces; > QTAILQ_HEAD(, ObjectProperty) properties; > uint32_t ref; > Object *parent; > @@ -381,6 +381,17 @@ struct TypeInfo > OBJECT_CLASS_CHECK(class, object_get_class(OBJECT(obj)), name) > > /** > + * InterfaceInfo: > + * @type: The name of the interface. > + * > + * The information associated with an interface. > + */ > +struct InterfaceInfo > +{ > +const char *type; > +}; > + > +/** > * InterfaceClass: > * @parent_class: the base class > * > @@ -390,26 +401,31 @@ struct TypeInfo > struct InterfaceClass > { > ObjectClass parent_class; > +/*< private >*/ > +ObjectClass *concrete_class; > }; > > +#define TYPE_INTERFACE "interface" > + > /** > - * InterfaceInfo: > - * @type: The name of the interface. > - * @interface_initfn: This method is called during class initialization and > is > - * used to initialize an interface associated with a class. This function > - * should initialize any default virtual functions for a class and/or > override > - * virtual functions in a parent class. > + * INTERFACE_CLASS: > + * @klass: class to cast from > * > - * The information associated with an interface. > + * Returns: An #InterfaceClass or raise an error if cast is invalid > */ > -struct InterfaceInfo > -{ > -const char *type; > +#define INTERFACE_CLASS(klass) \ > +OBJECT_CLASS_CHECK(InterfaceClass, klass, TYPE_INTERFACE) > > -void (*interface_initfn)(ObjectClass *class, void *data); > -}; > - > -#define TYPE_INTERFACE "interface" > +/** > + * INTERFACE_CHECK: > + * @interface: the type to return > + * @obj: the object to convert to an interface > + * @name: the interface type name > + * > + * Returns: @obj casted to @interface if cast is valid, otherwise raise > error. > + */ > +#define INTERFACE_CHECK(interface, obj, name) \ > +((interface *)interface_dynamic_cast_assert(OBJECT((obj)), (name))) > > /** > * object_new: > @@ -548,6 +564,24 @@ ObjectClass *object_class_dynamic_cast(ObjectClass > *klass, > const char *typename); > > /** > + * interface_dynamic_cast_assert: > + * @obj: the object to cast to an interface type > + * @typename: the type name of the interface > + * > + * Returns: @obj if @obj implements @typename, otherwise raise an error > + */ > +Object *interface_dynamic_cast_assert(Object *obj, const char *typename); > + > +/** > + * interface_dynamic_cast_assert: > + * @obj: the object to cast to an interface type > + * @typename: the type name of the interface > + * > + * Returns: @obj if @obj implements @typename, otherwise %NULL > + */ > +Object *interface_dynamic_cast(Object *obj, const char *typename); > + This is where bug was introduced for links. The link setter code uses object_dynamic_cast() which shortcuts the logic here, that is needed for casting interfaces. The new result is you can use interface with links cos the cast pukes. I have proposed a solution to this in my new revision (P3) of the axi-stream series. Regards, Peter > +/** > * object_class_get_name: > * @klass: The class to obtain the QOM typename for. > * > diff --git a/qom/object.c b/qom/object.c > index 6f839ad..aa26693 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -31,9 +31,7 @@ typedef struct TypeImpl TypeImpl; > > struct InterfaceImpl > { > -const char *parent; > -void (*interface_initfn)(ObjectClass *class, void *data); > -TypeImpl *type; > +const char *typename; > }; > > struct TypeImpl > @@ -63,14 +61,6 @@ s
[Qemu-devel] How to management KVM virtual machines via libvirt?
Hi all, I am trying to management the VMs created by KVM commandline. However, I found the libvirt cannot connect to the VMs or manage it from virsh. Can anybody provide any help? Best, Yi
Re: [Qemu-devel] How to management KVM virtual machines via libvirt?
CC'ed to libvirt-users. On Sat, Jun 16, 2012 at 07:00:59PM +0800, GaoYi wrote: > Hi all, > > I am trying to management the VMs created by KVM commandline. However, I > found the libvirt cannot connect to the VMs or manage it from virsh. Can > anybody provide any help? > Best, Shouldn't this go to libvirt mailing list? http://libvirt.org/contact.html Regards, chenwj -- Wei-Ren Chen (陳韋任) Computer Systems Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.) Tel:886-2-2788-3799 #1667 Homepage: http://people.cs.nctu.edu.tw/~chenwj
Re: [Qemu-devel] [PATCH v3 00/25] x86 AREG0 conversion
Am 16.06.2012 08:51, schrieb Blue Swirl: > On Sat, Jun 16, 2012 at 12:59 AM, Andreas Färber wrote: >> Am 09.06.2012 18:18, schrieb Blue Swirl: >>> v3: Rebased due to Makefile changes. If there are no objections, >>> I'll apply this next weekend. >> >> If you have it on some branch to test I'll give it a whirl tomorrow. > > URL git://repo.or.cz/qemu/blueswirl.git > http://repo.or.cz/r/qemu/blueswirl.git Thanks for rebasing and pushing. Unfortunately I'm seeing a regression booting openSUSE 12.1 64-bit GNOME Live CD [1] with qemu-system-x86_64: It hangs after initializing the mouse whereas on master it proceeds into the graphical installer. Andreas [1] http://software.opensuse.org/121/en -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH v2 35/41] postcopy: introduce helper functions for postcopy
Isaku Yamahata wrote: > On Thu, Jun 14, 2012 at 11:34:09PM +0200, Juan Quintela wrote: >> > +size_t umem_pages_size(uint64_t nr) >> > +{ >> > +return sizeof(struct umem_pages) + nr * sizeof(uint64_t); >> >> Can we make sure that the pgoffs field is aligned? I know that as it is >> now it is aligned, but better to be sure? > > It is already done by gcc extension, zero length array. Ah, I didn't knew that propierty of the zero arrays extension. thanks. >> >> Grr, we don't have a function that writes does a "safe_write". The most >> similar thing in qemu looks to be send_all(). > > So we should introduce something like qemu_safe_write/read? I guess so. If you look around, you will see that we have a lot of cases where we have this pattern. But that is not a problem ofthis patch, was already there. > >> Talking about looking, what protects that no other thread enters this >> function before this one calls madvise? Or I am losing something obvious? > > It is assumed that only main thread calls this function via iohandler. Ok. Can we add a comment then? Later, Juan.
[Qemu-devel] [PATCH] net: roll back qdev_prop_vlan
From: Zhi Yong Wu We're trying to preserve backward compatibility. This command-line break: x86_64-softmmu/qemu-system-x86_64 -net user,vlan=1 -device virtio-net-pci,vlan=1 Instead of dropping the qdev_prop_vlan completely the hw/qdev-properties.c code needs to call net/hub.h external functions to implement equivalent functionality. Signed-off-by: Zhi Yong Wu --- hw/qdev-properties.c | 76 ++ hw/qdev.h|3 ++ net.h|1 + net/hub.c| 25 net/hub.h|1 + 5 files changed, 106 insertions(+), 0 deletions(-) diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 1c13bda..91328eb 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -2,6 +2,7 @@ #include "qdev.h" #include "qerror.h" #include "blockdev.h" +#include "net/hub.h" void *qdev_get_prop_ptr(DeviceState *dev, Property *prop) { @@ -623,6 +624,81 @@ PropertyInfo qdev_prop_netdev = { .set = set_netdev, }; +/* --- vlan --- */ + +static int print_vlan(DeviceState *dev, Property *prop, char *dest, size_t len) +{ +NetClientState **ptr = qdev_get_prop_ptr(dev, prop); + +if (*ptr) { +unsigned int id; +if (!net_hub_id_for_client(*ptr, &id)) { +return snprintf(dest, len, "%d", id); +} +} + +return snprintf(dest, len, ""); +} + +static void get_vlan(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ +DeviceState *dev = DEVICE(obj); +Property *prop = opaque; +NetClientState **ptr = qdev_get_prop_ptr(dev, prop); +int64_t id = -1; + +if (*ptr) { +unsigned int hub_id; +net_hub_id_for_client(*ptr, &hub_id); +id = (int64_t)hub_id; +} + +visit_type_int(v, &id, name, errp); +} + +static void set_vlan(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ +DeviceState *dev = DEVICE(obj); +Property *prop = opaque; +NetClientState **ptr = qdev_get_prop_ptr(dev, prop); +Error *local_err = NULL; +int64_t id; +NetClientState *hubport; + +if (dev->state != DEV_STATE_CREATED) { +error_set(errp, QERR_PERMISSION_DENIED); +return; +} + +visit_type_int(v, &id, name, &local_err); +if (local_err) { +error_propagate(errp, local_err); +return; +} + +if (id == -1) { +*ptr = NULL; +return; +} + +hubport = net_hub_port_find(id); +if (!hubport) { +error_set(errp, QERR_INVALID_PARAMETER_VALUE, + name, prop->info->name); +return; +} +*ptr = hubport; +} + +PropertyInfo qdev_prop_vlan = { +.name = "vlan", +.print = print_vlan, +.get = get_vlan, +.set = set_vlan, +}; + /* --- pointer --- */ /* Not a proper property, just for dirty hacks. TODO Remove it! */ diff --git a/hw/qdev.h b/hw/qdev.h index edbf8fa..f4aea27 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -222,6 +222,7 @@ extern PropertyInfo qdev_prop_macaddr; extern PropertyInfo qdev_prop_losttickpolicy; extern PropertyInfo qdev_prop_drive; extern PropertyInfo qdev_prop_netdev; +extern PropertyInfo qdev_prop_vlan; extern PropertyInfo qdev_prop_pci_devfn; extern PropertyInfo qdev_prop_blocksize; @@ -276,6 +277,8 @@ extern PropertyInfo qdev_prop_blocksize; DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*) #define DEFINE_PROP_NETDEV(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, NetClientState*) +#define DEFINE_PROP_VLAN(_n, _s, _f) \ +DEFINE_PROP(_n, _s, _f, qdev_prop_vlan, NetClientState*) #define DEFINE_PROP_DRIVE(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_drive, BlockDriverState *) #define DEFINE_PROP_MACADDR(_n, _s, _f) \ diff --git a/net.h b/net.h index 08306a4..c4e56cc 100644 --- a/net.h +++ b/net.h @@ -22,6 +22,7 @@ typedef struct NICConf { #define DEFINE_NIC_PROPERTIES(_state, _conf)\ DEFINE_PROP_MACADDR("mac", _state, _conf.macaddr),\ +DEFINE_PROP_VLAN("vlan", _state, _conf.peer), \ DEFINE_PROP_NETDEV("netdev", _state, _conf.peer), \ DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1) diff --git a/net/hub.c b/net/hub.c index efd90b5..001f818 100644 --- a/net/hub.c +++ b/net/hub.c @@ -205,6 +205,31 @@ NetClientState *net_hub_find_client_by_name(unsigned int hub_id, } /** + * Find a available port on a hub; otherwise create one new port + */ +NetClientState *net_hub_port_find(unsigned int hub_id) +{ +NetHub *hub; +NetHubPort *port; +NetClientState *nc; + +QLIST_FOREACH(hub, &hubs, next) { +if (hub->id == hub_id) { +QLIST_FOREACH(port, &hub->ports, next) { +nc = port->nc.peer; +if (!nc) { +return &(port->nc); +} +
Re: [Qemu-devel] ARM QEMU/KVM and TrustZone
> On 22 May 2012 13:22, Peter Maydell wrote: >> Historically for QEMU we haven't implemented TrustZone support even >> though we claim to emulate CPUs that provide it. Instead we provide a >> CPU which mostly looks like a variant of the real thing without the >> TrustZone feature. We then bolt on a few extra cp15 registers (eg the >> SCR) as a pragmatic move to get Linux guests to run. Now we're also >> dealing with KVM on ARM I'd like to define things a bit more solidly >> so KVM and TCG agree on what the CPU model they present is. >> >> There are several possible environments we could provide >> to a guest: >> (1) a CPU with full TrustZone support >> (2) a CPU without TrustZone at all >> (3) a TZ CPU running in NonSecure PL0/PL1 >> (4) a TZ CPU running in Secure PL0/PL1 >> >> In some ways (1) is the "purist" solution -- emulate exactly what the >> hardware does. However: >> >> * on TCG it would require a lot of work, including new functionality >> in core QEMU (to support having different CPU cores being able to >> see different views of memory, and having the S/NS attribute >> attached to memory transactions) >> >> * it isn't possible in KVM, because the ARM Virtualization Extensions >> don't allow you to fake the CPSR a guest sees, and so you can't >> make the guest believe it is in Monitor mode >> >> Option (2) is architecturally sanctioned (ie TrustZone is an optional >> feature, not mandatory), but it doesn't correspond to real CPUs, in >> that the hardware Cortex-A8/A9/A15 always have TrustZone. So we're >> modelling something that doesn't really exist. >> >> Options (3) and (4) correspond to the environment an OS guest >> typically actually uses on hardware. For ARM's devboards (versatile >> express etc) Linux runs in the Secure world but it doesn't actually >> use any of the TrustZone functionality, it's just a "give me full >> access to everything" setup. For just about every other ARM system, >> the boot rom or equivalent keeps Secure world to itself, and the OS >> kernel runs in the NonSecure world. (This typically means that the >> boot rom provides a set of board-specific entry points via the Secure >> Monitor Call (SMC) instruction for doing operations like "invalidate >> whole L2 cache" which require secure privileges.) >> Is there anything preventing people from writing a small bootloader that switches into non-secure mode and runs kernels there as a general approach (apart from laziness)? >> Proposal: >> >> My suggestion is that we present the guest with a view that looks like >> a sort of superset of (2) (3) and (4), ie sufficient that a guest >> expecting any of those environments can run. In particular: >> >> * no cp15 registers have secure/nonsecure banking >> * there is only one memory space visible >> * secure-access-only permissions are not enforced >> * the handful of only-in-trustzone registers are implemented >> (eg VBAR, MVBAR) >> * we implement a "fake monitor mode" >> >> The aim of the "fake monitor mode" is to allow us to provide fake >> qemu-specific bootroms which implement whatever the board's SMC >> interface is, without having to write specific KVM kernel code for >> each board. So we don't have to run arbitrary secure-world guest code. >> The rules are: >> * on an SMC instruction we enter the guest at the SMC vector >> as defined by the MVBAR (monitor vector base address register) >> * we actually run with the same access permissions as above >> (and under KVM if you look at CPSR.M it will tell you you're >> in Supervisor mode) >> * return from the SMC is via a standard exception return insn >> * we don't implement the separate memory space for the secure >> world. (This implies that you need to find space in the >> non-secure world's physical memory map for the bootrom shim; >> not a big deal I think since we already have a requirement >> for some space to put QEMU's arm_boot trivial bootloader.) >> you could have a separate set of stage-2 translation tables for this and keep things separate for real (or would we rely on fake-SMC code to directly be able to read fake-non-secure data, which is still possible through a different memory map I guess). >> The code written for this fake monitor mode environment is likely to >> be able to work OK if we ever implement full TrustZone support in TCG >> QEMU. >> what kind of operations would be required from SMC calls in a KVM guest setting? I can see this in an embedded market, but are they not likely to even capture Hyp mode already and set things up as required? What I mean is, if KVM is currently targeting Calxeda-type setups will we ever run kernels that require SMC operations as guests? It feels a bit premature to implement all this. >> Work required: >> >> * Documentation: the general principles as listed above >> * TCG: make sure we have implementations of all the TZ registers >> * TCG: implement the SMC and fake-monitor-mode >> (I already have patches from Nokia in the
Re: [Qemu-devel] [PATCH v3 00/25] x86 AREG0 conversion
On Sat, Jun 16, 2012 at 1:15 PM, Andreas Färber wrote: > Am 16.06.2012 08:51, schrieb Blue Swirl: >> On Sat, Jun 16, 2012 at 12:59 AM, Andreas Färber wrote: >>> Am 09.06.2012 18:18, schrieb Blue Swirl: v3: Rebased due to Makefile changes. If there are no objections, I'll apply this next weekend. >>> >>> If you have it on some branch to test I'll give it a whirl tomorrow. >> >> URL git://repo.or.cz/qemu/blueswirl.git >> http://repo.or.cz/r/qemu/blueswirl.git > > Thanks for rebasing and pushing. > > Unfortunately I'm seeing a regression booting openSUSE 12.1 64-bit GNOME > Live CD [1] with qemu-system-x86_64: It hangs after initializing the > mouse whereas on master it proceeds into the graphical installer. > > Andreas > > [1] http://software.opensuse.org/121/en The site does not respond. Could you try to bisect which patch causes the problem? > > -- > SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany > GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH] w32: Fix broken build (missing include file)
On 6/12/12, Markus Armbruster wrote: > Paolo Bonzini writes: > >> Il 11/06/2012 03:57, Wen Congyang ha scritto: dump.* use GPL2 instead of GPL2+. Please fix that! >> >> Wen, do you have permissions to release your new files under GPLv2 or >> later? > > Don't we require GPLv2+ for all contributions now? If not, we should. > I think it's not possible for all contributions. The BSD-like license can not be removed from a file once it's there. So, the contributions made to such file do inherit this license, unless they have other license written directly in the source code. (This is btw, why you still have to fix the license violation [1,2] happened in 2010). Moreover, there are explicit places in QEMU source tree [3] which say BSD-like is the only acceptable license. Artyom 1. http://lists.gnu.org/archive/html/qemu-devel/2010-12/msg01228.html 2. http://lists.gnu.org/archive/html/qemu-devel/2012-05/msg02408.html 3. http://git.qemu.org/?p=qemu.git;a=blob_plain;f=tcg/LICENSE;hb=master -- Regards, Artyom Tarasenko solaris/sparc under qemu blog: http://tyom.blogspot.com/search/label/qemu
Re: [Qemu-devel] [PATCH] w32: Fix broken build (missing include file)
Am 16.06.2012 20:07, schrieb Artyom Tarasenko: > On 6/12/12, Markus Armbruster wrote: >> Paolo Bonzini writes: >> >>> Il 11/06/2012 03:57, Wen Congyang ha scritto: > dump.* use GPL2 instead of GPL2+. Please fix that! >>> >>> Wen, do you have permissions to release your new files under GPLv2 or >>> later? >> >> Don't we require GPLv2+ for all contributions now? If not, we should. >> > > I think it's not possible for all contributions. [snip] You're reading this out of context. It's about GPLv2 vs. GPLv2+, not about GPL vs. BSD/MIT/... Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH] w32: Fix broken build (missing include file)
On Sat, Jun 16, 2012 at 8:31 PM, Andreas Färber wrote: > Am 16.06.2012 20:07, schrieb Artyom Tarasenko: >> On 6/12/12, Markus Armbruster wrote: >>> Paolo Bonzini writes: >>> Il 11/06/2012 03:57, Wen Congyang ha scritto: >> dump.* use GPL2 instead of GPL2+. Please fix that! Wen, do you have permissions to release your new files under GPLv2 or later? >>> >>> Don't we require GPLv2+ for all contributions now? If not, we should. >>> >> >> I think it's not possible for all contributions. > [snip] > > You're reading this out of context. It's about GPLv2 vs. GPLv2+, not > about GPL vs. BSD/MIT/... But still, it's not possible for all contributions, right? To sum this up: GPL v2+ are allowed non-GPL contributions are allowed GPL v2- are not allowed. Am I missing something? Artyom > Andreas > > > -- > SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany > GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg -- Regards, Artyom Tarasenko solaris/sparc under qemu blog: http://tyom.blogspot.com/search/label/qemu
Re: [Qemu-devel] ARM QEMU/KVM and TrustZone
On 16 June 2012 18:37, Christoffer Dall wrote: >> On 22 May 2012 13:22, Peter Maydell wrote: >>> Historically for QEMU we haven't implemented TrustZone support even >>> though we claim to emulate CPUs that provide it. Instead we provide a >>> CPU which mostly looks like a variant of the real thing without the >>> TrustZone feature. We then bolt on a few extra cp15 registers (eg the >>> SCR) as a pragmatic move to get Linux guests to run. Now we're also >>> dealing with KVM on ARM I'd like to define things a bit more solidly >>> so KVM and TCG agree on what the CPU model they present is. >>> >>> There are several possible environments we could provide >>> to a guest: >>> (1) a CPU with full TrustZone support >>> (2) a CPU without TrustZone at all >>> (3) a TZ CPU running in NonSecure PL0/PL1 >>> (4) a TZ CPU running in Secure PL0/PL1 >>> >>> In some ways (1) is the "purist" solution -- emulate exactly what the >>> hardware does. However: >>> >>> * on TCG it would require a lot of work, including new functionality >>> in core QEMU (to support having different CPU cores being able to >>> see different views of memory, and having the S/NS attribute >>> attached to memory transactions) >>> >>> * it isn't possible in KVM, because the ARM Virtualization Extensions >>> don't allow you to fake the CPSR a guest sees, and so you can't >>> make the guest believe it is in Monitor mode >>> >>> Option (2) is architecturally sanctioned (ie TrustZone is an optional >>> feature, not mandatory), but it doesn't correspond to real CPUs, in >>> that the hardware Cortex-A8/A9/A15 always have TrustZone. So we're >>> modelling something that doesn't really exist. >>> >>> Options (3) and (4) correspond to the environment an OS guest >>> typically actually uses on hardware. For ARM's devboards (versatile >>> express etc) Linux runs in the Secure world but it doesn't actually >>> use any of the TrustZone functionality, it's just a "give me full >>> access to everything" setup. For just about every other ARM system, >>> the boot rom or equivalent keeps Secure world to itself, and the OS >>> kernel runs in the NonSecure world. (This typically means that the >>> boot rom provides a set of board-specific entry points via the Secure >>> Monitor Call (SMC) instruction for doing operations like "invalidate >>> whole L2 cache" which require secure privileges.) >>> > > Is there anything preventing people from writing a small bootloader > that switches into non-secure mode and runs kernels there as a general > approach (apart from laziness)? I'm not sure what you're suggesting here. Mostly kernels do run in NS mode on hardware, except for on ARM devboards. On ARM devboards if you try to run the kernel in NS mode it will fall over the first time it tries something that needs secure world privileges. For KVM my rule of thumb is that it needs to run the same kernel the hw runs. To some extent the small boot loader would be the thing I describe as a 'fake bootrom' below. >>> Proposal: >>> >>> My suggestion is that we present the guest with a view that looks like >>> a sort of superset of (2) (3) and (4), ie sufficient that a guest >>> expecting any of those environments can run. In particular: >>> >>> * no cp15 registers have secure/nonsecure banking >>> * there is only one memory space visible >>> * secure-access-only permissions are not enforced >>> * the handful of only-in-trustzone registers are implemented >>> (eg VBAR, MVBAR) >>> * we implement a "fake monitor mode" >>> >>> The aim of the "fake monitor mode" is to allow us to provide fake >>> qemu-specific bootroms which implement whatever the board's SMC >>> interface is, without having to write specific KVM kernel code for >>> each board. So we don't have to run arbitrary secure-world guest code. >>> The rules are: >>> * on an SMC instruction we enter the guest at the SMC vector >>> as defined by the MVBAR (monitor vector base address register) >>> * we actually run with the same access permissions as above >>> (and under KVM if you look at CPSR.M it will tell you you're >>> in Supervisor mode) >>> * return from the SMC is via a standard exception return insn >>> * we don't implement the separate memory space for the secure >>> world. (This implies that you need to find space in the >>> non-secure world's physical memory map for the bootrom shim; >>> not a big deal I think since we already have a requirement >>> for some space to put QEMU's arm_boot trivial bootloader.) >>> > > you could have a separate set of stage-2 translation tables for this > and keep things separate for real (or would we rely on fake-SMC code > to directly be able to read fake-non-secure data, which is still > possible through a different memory map I guess). I'm trying to keep things simple (and separate memory maps for TCG is a bit tricky). We can't make the monitor mode really look like monitor mode, so there's not much point trying to implement all the difficult comp
[Qemu-devel] [Bug 1014099] [NEW] hw/esp.c does not properly deal with TEST_UNIT_READY in NetBSD/sparc
Public bug reported: The NetBSD ncr53c9x.c driver does a TEST_UNIT_READY command with SELATN but dma disabled sometimes (early during bus enumeration). This is fine, as the command will not produce nor consume any data, and works on real hardware. However, the qemu emulation does not allow this (for reasons I don't understand). The change below fixes the problem. ** Affects: qemu Importance: Undecided Status: New -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1014099 Title: hw/esp.c does not properly deal with TEST_UNIT_READY in NetBSD/sparc Status in QEMU: New Bug description: The NetBSD ncr53c9x.c driver does a TEST_UNIT_READY command with SELATN but dma disabled sometimes (early during bus enumeration). This is fine, as the command will not produce nor consume any data, and works on real hardware. However, the qemu emulation does not allow this (for reasons I don't understand). The change below fixes the problem. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1014099/+subscriptions
[Qemu-devel] [Bug 1014099] Re: hw/esp.c does not properly deal with TEST_UNIT_READY in NetBSD/sparc
** Patch added: "esp.c.patch" https://bugs.launchpad.net/bugs/1014099/+attachment/3192643/+files/esp.c.patch -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1014099 Title: hw/esp.c does not properly deal with TEST_UNIT_READY in NetBSD/sparc Status in QEMU: New Bug description: The NetBSD ncr53c9x.c driver does a TEST_UNIT_READY command with SELATN but dma disabled sometimes (early during bus enumeration). This is fine, as the command will not produce nor consume any data, and works on real hardware. However, the qemu emulation does not allow this (for reasons I don't understand). The change below fixes the problem. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1014099/+subscriptions
[Qemu-devel] [Bug 1014099] Re: hw/esp.c does not properly deal with TEST_UNIT_READY in NetBSD/sparc
Guess I understand the code now - so here is a working version - though it may be considered slightly hackish ** Patch added: "esp.c.patch" https://bugs.launchpad.net/qemu/+bug/1014099/+attachment/3192942/+files/esp.c.patch ** Patch removed: "esp.c.patch" https://bugs.launchpad.net/qemu/+bug/1014099/+attachment/3192643/+files/esp.c.patch -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1014099 Title: hw/esp.c does not properly deal with TEST_UNIT_READY in NetBSD/sparc Status in QEMU: New Bug description: The NetBSD ncr53c9x.c driver does a TEST_UNIT_READY command with SELATN but dma disabled sometimes (early during bus enumeration). This is fine, as the command will not produce nor consume any data, and works on real hardware. However, the qemu emulation does not allow this (for reasons I don't understand). The change below fixes the problem. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1014099/+subscriptions
Re: [Qemu-devel] ARM QEMU/KVM and TrustZone
Hm, one memory space, but what about write access restrictions, e.g. for Non-Secure or Secure worlds for some memory addresses/blocks? Best regards, Anton Kochkov. On Sat, Jun 16, 2012 at 9:37 PM, Christoffer Dall wrote: >> On 22 May 2012 13:22, Peter Maydell wrote: >>> Historically for QEMU we haven't implemented TrustZone support even >>> though we claim to emulate CPUs that provide it. Instead we provide a >>> CPU which mostly looks like a variant of the real thing without the >>> TrustZone feature. We then bolt on a few extra cp15 registers (eg the >>> SCR) as a pragmatic move to get Linux guests to run. Now we're also >>> dealing with KVM on ARM I'd like to define things a bit more solidly >>> so KVM and TCG agree on what the CPU model they present is. >>> >>> There are several possible environments we could provide >>> to a guest: >>> (1) a CPU with full TrustZone support >>> (2) a CPU without TrustZone at all >>> (3) a TZ CPU running in NonSecure PL0/PL1 >>> (4) a TZ CPU running in Secure PL0/PL1 >>> >>> In some ways (1) is the "purist" solution -- emulate exactly what the >>> hardware does. However: >>> >>> * on TCG it would require a lot of work, including new functionality >>> in core QEMU (to support having different CPU cores being able to >>> see different views of memory, and having the S/NS attribute >>> attached to memory transactions) >>> >>> * it isn't possible in KVM, because the ARM Virtualization Extensions >>> don't allow you to fake the CPSR a guest sees, and so you can't >>> make the guest believe it is in Monitor mode >>> >>> Option (2) is architecturally sanctioned (ie TrustZone is an optional >>> feature, not mandatory), but it doesn't correspond to real CPUs, in >>> that the hardware Cortex-A8/A9/A15 always have TrustZone. So we're >>> modelling something that doesn't really exist. >>> >>> Options (3) and (4) correspond to the environment an OS guest >>> typically actually uses on hardware. For ARM's devboards (versatile >>> express etc) Linux runs in the Secure world but it doesn't actually >>> use any of the TrustZone functionality, it's just a "give me full >>> access to everything" setup. For just about every other ARM system, >>> the boot rom or equivalent keeps Secure world to itself, and the OS >>> kernel runs in the NonSecure world. (This typically means that the >>> boot rom provides a set of board-specific entry points via the Secure >>> Monitor Call (SMC) instruction for doing operations like "invalidate >>> whole L2 cache" which require secure privileges.) >>> > > Is there anything preventing people from writing a small bootloader > that switches into non-secure mode and runs kernels there as a general > approach (apart from laziness)? > >>> Proposal: >>> >>> My suggestion is that we present the guest with a view that looks like >>> a sort of superset of (2) (3) and (4), ie sufficient that a guest >>> expecting any of those environments can run. In particular: >>> >>> * no cp15 registers have secure/nonsecure banking >>> * there is only one memory space visible >>> * secure-access-only permissions are not enforced >>> * the handful of only-in-trustzone registers are implemented >>> (eg VBAR, MVBAR) >>> * we implement a "fake monitor mode" >>> >>> The aim of the "fake monitor mode" is to allow us to provide fake >>> qemu-specific bootroms which implement whatever the board's SMC >>> interface is, without having to write specific KVM kernel code for >>> each board. So we don't have to run arbitrary secure-world guest code. >>> The rules are: >>> * on an SMC instruction we enter the guest at the SMC vector >>> as defined by the MVBAR (monitor vector base address register) >>> * we actually run with the same access permissions as above >>> (and under KVM if you look at CPSR.M it will tell you you're >>> in Supervisor mode) >>> * return from the SMC is via a standard exception return insn >>> * we don't implement the separate memory space for the secure >>> world. (This implies that you need to find space in the >>> non-secure world's physical memory map for the bootrom shim; >>> not a big deal I think since we already have a requirement >>> for some space to put QEMU's arm_boot trivial bootloader.) >>> > > you could have a separate set of stage-2 translation tables for this > and keep things separate for real (or would we rely on fake-SMC code > to directly be able to read fake-non-secure data, which is still > possible through a different memory map I guess). > >>> The code written for this fake monitor mode environment is likely to >>> be able to work OK if we ever implement full TrustZone support in TCG >>> QEMU. >>> > > what kind of operations would be required from SMC calls in a KVM > guest setting? I can see this in an embedded market, but are they not > likely to even capture Hyp mode already and set things up as required? > What I mean is, if KVM is currently targeting Calxeda-type setups will > we ever run kernels t
[Qemu-devel] [PATCH] checkpatch: Add QEMU specific rule
The new rule detects two wrong variants of QEMU. It was tested with commit b5a8fe5e. Signed-off-by: Stefan Weil --- scripts/checkpatch.pl |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 8850a5f..b98dc6c 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2849,6 +2849,11 @@ sub process { ERROR("lockdep_no_validate class is reserved for device->mutex.\n" . $herecurr); } } + +# QEMU specific tests + if ($rawline =~ /\b(?:Qemu|QEmu)\b/) { + WARN("use QEMU instead of Qemu or QEmu\n" . $herecurr); + } } # If we have no input at all, then there is nothing to report on -- 1.7.0.4
Re: [Qemu-devel] [PATCH] Fix for qemu crash on assertion error when adding PCI passthru device.
Michael, Thanks for the review. I added the unparent to the qdev_free. --- hw/qdev.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index d2dc28b..ed1328d 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -264,6 +264,7 @@ void qdev_init_nofail(DeviceState *dev) /* Unlink device from bus and free the structure. */ void qdev_free(DeviceState *dev) { +object_unparent(OBJECT(dev)); object_delete(OBJECT(dev)); } -- 1.7.1 -Original Message- From: Michael S. Tsirkin [mailto:m...@redhat.com] Sent: Tuesday, June 12, 2012 1:27 AM To: Ma, Stephen B. Cc: 'qemu-devel@nongnu.org' Subject: Re: [PATCH] Fix for qemu crash on assertion error when adding PCI passthru device. On Tue, Jun 12, 2012 at 04:31:20AM +, Ma, Stephen B. wrote: > diff --git a/hw/qdev.c b/hw/qdev.c > index 6a8f6bd..d2dc28b 100644 > --- a/hw/qdev.c > +++ b/hw/qdev.c > @@ -139,7 +139,7 @@ DeviceState *qdev_try_create(BusState *bus, const char > *type) > /* Initialize a device. Device properties should be set before calling > this function. IRQs and MMIO regions should be connected/mapped after > calling this function. > - On failure, destroy the device and return negative value. > + On failure, return a negative value. > Return 0 on success. */ > int qdev_init(DeviceState *dev) > { Yes, I agree. qdev_init did now allocate the device so it should not free it. > @@ -150,7 +150,6 @@ int qdev_init(DeviceState *dev) > > rc = dc->init(dev); > if (rc < 0) { > -qdev_free(dev); > return rc; > } > Another thing we need to fix is unparent the device in qdev_free. -- MST