mirror of
https://github.com/qemu/qemu.git
synced 2025-08-13 02:14:36 +00:00

This patch adds a new source module, xen-bus-helper.c, which builds on basic libxenstore primitives to provide functions to create (setting permissions appropriately) and destroy xenstore areas, and functions to 'printf' and 'scanf' nodes therein. The main xen-bus code then uses these primitives [1] to initialize and destroy the frontend and backend areas for a XenDevice during realize and unrealize respectively. The 'xen-block' implementation is extended with a 'get_name' method that returns the VBD number. This number is required to 'name' the xenstore areas. NOTE: An exit handler is also added to make sure the xenstore areas are cleaned up if QEMU terminates without devices being unrealized. [1] The 'scanf' functions are actually not yet needed, but they will be needed by code delivered in subsequent patches. Signed-off-by: Paul Durrant <paul.durrant@citrix.com> Reviewed-by: Anthony Perard <anthony.perard@citrix.com> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
68 lines
1.8 KiB
C
68 lines
1.8 KiB
C
/*
|
|
* Copyright (c) 2018 Citrix Systems Inc.
|
|
*
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
* See the COPYING file in the top-level directory.
|
|
*/
|
|
|
|
#ifndef HW_XEN_BUS_H
|
|
#define HW_XEN_BUS_H
|
|
|
|
#include "hw/xen/xen_common.h"
|
|
#include "hw/sysbus.h"
|
|
|
|
typedef struct XenDevice {
|
|
DeviceState qdev;
|
|
domid_t frontend_id;
|
|
char *name;
|
|
char *backend_path, *frontend_path;
|
|
enum xenbus_state backend_state, frontend_state;
|
|
Notifier exit;
|
|
} XenDevice;
|
|
|
|
typedef char *(*XenDeviceGetName)(XenDevice *xendev, Error **errp);
|
|
typedef void (*XenDeviceRealize)(XenDevice *xendev, Error **errp);
|
|
typedef void (*XenDeviceUnrealize)(XenDevice *xendev, Error **errp);
|
|
|
|
typedef struct XenDeviceClass {
|
|
/*< private >*/
|
|
DeviceClass parent_class;
|
|
/*< public >*/
|
|
const char *backend;
|
|
const char *device;
|
|
XenDeviceGetName get_name;
|
|
XenDeviceRealize realize;
|
|
XenDeviceUnrealize unrealize;
|
|
} XenDeviceClass;
|
|
|
|
#define TYPE_XEN_DEVICE "xen-device"
|
|
#define XEN_DEVICE(obj) \
|
|
OBJECT_CHECK(XenDevice, (obj), TYPE_XEN_DEVICE)
|
|
#define XEN_DEVICE_CLASS(class) \
|
|
OBJECT_CLASS_CHECK(XenDeviceClass, (class), TYPE_XEN_DEVICE)
|
|
#define XEN_DEVICE_GET_CLASS(obj) \
|
|
OBJECT_GET_CLASS(XenDeviceClass, (obj), TYPE_XEN_DEVICE)
|
|
|
|
typedef struct XenBus {
|
|
BusState qbus;
|
|
domid_t backend_id;
|
|
struct xs_handle *xsh;
|
|
} XenBus;
|
|
|
|
typedef struct XenBusClass {
|
|
/*< private >*/
|
|
BusClass parent_class;
|
|
} XenBusClass;
|
|
|
|
#define TYPE_XEN_BUS "xen-bus"
|
|
#define XEN_BUS(obj) \
|
|
OBJECT_CHECK(XenBus, (obj), TYPE_XEN_BUS)
|
|
#define XEN_BUS_CLASS(class) \
|
|
OBJECT_CLASS_CHECK(XenBusClass, (class), TYPE_XEN_BUS)
|
|
#define XEN_BUS_GET_CLASS(obj) \
|
|
OBJECT_GET_CLASS(XenBusClass, (obj), TYPE_XEN_BUS)
|
|
|
|
void xen_bus_init(void);
|
|
|
|
#endif /* HW_XEN_BUS_H */
|