I've written what I believe is a minimal custom device to test my understanding of the QOM and QEMU in general. Below is the relevant code with comments omitted. Unfortunately, when I start the guest and pass my device name as a command line argument, it fails to find my device and exits. I am issuing:
qemu-system-x86_64 -device hello-world-device ...
How can I make QEMU aware of my device? What steps do I need to take to properly build my device?
I can see an objects list in the folder I placed my source into (qemu/hw/misc), but I can't find where the other targets are defined to add in a target for my new device. The code:
#include "qom/object.h"
#include "hw/qdev-core.h"
#define TYPE_HELLO "hello-world-device"
#define HELLO(obj) OBJECT_CHECK(HelloState, (obj), TYPE_HELLO)
typedef struct{
DeviceClass parent_obj;
uint8_t member0, member1;
} HelloState;
static const TypeInfo hello_info = {
.name = TYPE_HELLO,
.parent = TYPE_DEVICE,
.instance_size = sizeof(HelloState),
.class_init = class_init,
};
static void class_init(ObjectClass *klass, void *data){
DeviceClass *dc = DEVICE_CLASS(klass);
}
static void hello_register_types(void){
type_register_static(&hello_info);
}
type_init(hello_register_types)