2008-07-19 01:04:37 +02:00
|
|
|
Index: xen-3.3.0-testing/tools/ioemu/hw/ide.c
|
2007-04-26 01:53:07 +02:00
|
|
|
===================================================================
|
2008-07-19 01:04:37 +02:00
|
|
|
--- xen-3.3.0-testing.orig/tools/ioemu/hw/ide.c
|
|
|
|
+++ xen-3.3.0-testing/tools/ioemu/hw/ide.c
|
|
|
|
@@ -406,6 +406,9 @@ typedef struct PCIIDEState {
|
2007-03-06 09:12:51 +01:00
|
|
|
int type; /* see IDE_TYPE_xxx */
|
|
|
|
} PCIIDEState;
|
|
|
|
|
|
|
|
+static PCIIDEState *principal_ide_controller;
|
|
|
|
+extern FILE *logfile;
|
|
|
|
+
|
2007-12-20 16:46:41 +01:00
|
|
|
#if defined(__ia64__)
|
|
|
|
#include <xen/hvm/ioreq.h>
|
2007-03-06 09:12:51 +01:00
|
|
|
|
2008-07-19 01:04:37 +02:00
|
|
|
@@ -2305,6 +2308,27 @@ static void ide_reset(IDEState *s)
|
2007-03-06 09:12:51 +01:00
|
|
|
ide_dummy_transfer_stop(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
+void ide_unplug_harddisks(void)
|
|
|
|
+{
|
|
|
|
+ IDEState *s;
|
|
|
|
+ int i;
|
|
|
|
+
|
|
|
|
+ if (!principal_ide_controller) {
|
|
|
|
+ fprintf(logfile, "No principal controller?\n");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for (i = 0; i < 4; i++) {
|
|
|
|
+ s = principal_ide_controller->ide_if + i;
|
|
|
|
+ if (!s->bs)
|
|
|
|
+ continue; /* drive not present */
|
|
|
|
+ if (s->is_cdrom)
|
|
|
|
+ continue; /* cdrom */
|
|
|
|
+ /* Is a hard disk, unplug it. */
|
|
|
|
+ s->bs = NULL;
|
|
|
|
+ ide_reset(s);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
struct partition {
|
|
|
|
uint8_t boot_ind; /* 0x80 - active */
|
|
|
|
uint8_t head; /* starting head */
|
2008-07-19 01:04:37 +02:00
|
|
|
@@ -2707,6 +2731,9 @@ void pci_cmd646_ide_init(PCIBus *bus, Bl
|
2007-03-06 09:12:51 +01:00
|
|
|
sizeof(PCIIDEState),
|
|
|
|
-1,
|
|
|
|
NULL, NULL);
|
|
|
|
+ if (principal_ide_controller)
|
|
|
|
+ abort();
|
|
|
|
+ principal_ide_controller = d;
|
|
|
|
d->type = IDE_TYPE_CMD646;
|
|
|
|
pci_conf = d->dev.config;
|
|
|
|
pci_conf[0x00] = 0x95; // CMD646
|
2008-07-19 01:04:37 +02:00
|
|
|
@@ -2884,6 +2911,9 @@ void pci_piix_ide_init(PCIBus *bus, Bloc
|
2007-03-06 09:12:51 +01:00
|
|
|
NULL, NULL);
|
|
|
|
d->type = IDE_TYPE_PIIX3;
|
|
|
|
|
|
|
|
+ if (principal_ide_controller)
|
|
|
|
+ abort();
|
2008-03-06 02:36:51 +01:00
|
|
|
+ principal_ide_controller = d;
|
|
|
|
pci_conf = d->dev.config;
|
|
|
|
pci_conf[0x00] = 0x86; // Intel
|
|
|
|
pci_conf[0x01] = 0x80;
|
2008-07-19 01:04:37 +02:00
|
|
|
@@ -2930,6 +2960,9 @@ void pci_piix3_ide_init(PCIBus *bus, Blo
|
2008-03-06 02:36:51 +01:00
|
|
|
NULL, NULL);
|
|
|
|
d->type = IDE_TYPE_PIIX3;
|
|
|
|
|
|
|
|
+ if (principal_ide_controller)
|
|
|
|
+ abort();
|
2007-03-06 09:12:51 +01:00
|
|
|
+ principal_ide_controller = d;
|
|
|
|
pci_conf = d->dev.config;
|
|
|
|
pci_conf[0x00] = 0x86; // Intel
|
|
|
|
pci_conf[0x01] = 0x80;
|
2008-07-19 01:04:37 +02:00
|
|
|
Index: xen-3.3.0-testing/tools/ioemu/hw/pci.c
|
2007-04-26 01:53:07 +02:00
|
|
|
===================================================================
|
2008-07-19 01:04:37 +02:00
|
|
|
--- xen-3.3.0-testing.orig/tools/ioemu/hw/pci.c
|
|
|
|
+++ xen-3.3.0-testing/tools/ioemu/hw/pci.c
|
|
|
|
@@ -594,6 +594,28 @@ void pci_nic_init(PCIBus *bus, NICInfo *
|
2007-03-06 09:12:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+void pci_unplug_netifs(void)
|
|
|
|
+{
|
|
|
|
+ PCIBus *bus;
|
|
|
|
+ int x;
|
|
|
|
+
|
|
|
|
+ /* We only support one PCI bus */
|
|
|
|
+ for (bus = first_bus; bus; bus = NULL) {
|
|
|
|
+ for (x = 0; x < 256; x++) {
|
|
|
|
+ if (bus->devices[x] &&
|
|
|
|
+ bus->devices[x]->config[0xa] == 0 &&
|
|
|
|
+ bus->devices[x]->config[0xb] == 2) {
|
|
|
|
+ /* Found a netif. Remove it from the bus. Note that
|
|
|
|
+ we don't free it here, since there could still be
|
|
|
|
+ references to it floating around. There are only
|
|
|
|
+ ever one or two structures leaked, and it's not
|
|
|
|
+ worth finding them all. */
|
|
|
|
+ bus->devices[x] = NULL;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
2007-12-20 16:46:41 +01:00
|
|
|
+
|
|
|
|
typedef struct {
|
|
|
|
PCIDevice dev;
|
|
|
|
PCIBus *bus;
|
2008-07-19 01:04:37 +02:00
|
|
|
Index: xen-3.3.0-testing/tools/ioemu/hw/xen_platform.c
|
2007-04-26 01:53:07 +02:00
|
|
|
===================================================================
|
2008-07-19 01:04:37 +02:00
|
|
|
--- xen-3.3.0-testing.orig/tools/ioemu/hw/xen_platform.c
|
|
|
|
+++ xen-3.3.0-testing/tools/ioemu/hw/xen_platform.c
|
2008-03-06 02:36:51 +01:00
|
|
|
@@ -23,15 +23,53 @@
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
#include "vl.h"
|
|
|
|
+#include <xc_private.h>
|
|
|
|
|
|
|
|
#include <xenguest.h>
|
2007-03-06 09:12:51 +01:00
|
|
|
|
|
|
|
extern FILE *logfile;
|
|
|
|
|
|
|
|
+static uint32_t ioport_base;
|
2007-12-20 16:46:41 +01:00
|
|
|
+
|
|
|
|
+static void platform_ioport_write(void *opaque, uint32_t addr, uint32_t val)
|
|
|
|
+{
|
2007-03-06 09:12:51 +01:00
|
|
|
+ DECLARE_DOMCTL;
|
|
|
|
+ int rc;
|
2007-04-26 01:53:07 +02:00
|
|
|
+
|
2007-12-20 16:46:41 +01:00
|
|
|
+ if (val == 0)
|
|
|
|
+ qemu_invalidate_map_cache();
|
2007-03-06 09:12:51 +01:00
|
|
|
+
|
|
|
|
+ switch (addr - ioport_base) {
|
|
|
|
+ case 0:
|
2007-04-26 01:53:07 +02:00
|
|
|
+ fprintf(logfile, "Init hypercall page %x, addr %x.\n", val, addr);
|
|
|
|
+ domctl.domain = (domid_t)domid;
|
|
|
|
+ domctl.u.hypercall_init.gmfn = val;
|
|
|
|
+ domctl.cmd = XEN_DOMCTL_hypercall_init;
|
|
|
|
+ rc = xc_domctl(xc_handle, &domctl);
|
|
|
|
+ fprintf(logfile, "result -> %d.\n", rc);
|
|
|
|
+ break;
|
2007-03-06 09:12:51 +01:00
|
|
|
+ case 4:
|
2007-04-26 01:53:07 +02:00
|
|
|
+ fprintf(logfile, "Disconnect IDE hard disk...\n");
|
|
|
|
+ ide_unplug_harddisks();
|
|
|
|
+ fprintf(logfile, "Disconnect netifs...\n");
|
|
|
|
+ pci_unplug_netifs();
|
|
|
|
+ fprintf(logfile, "Shutdown taps...\n");
|
|
|
|
+ net_tap_shutdown_all();
|
|
|
|
+ fprintf(logfile, "Done.\n");
|
|
|
|
+ break;
|
2007-03-06 09:12:51 +01:00
|
|
|
+ default:
|
2007-04-26 01:53:07 +02:00
|
|
|
+ fprintf(logfile, "Write to bad port %x (base %x) on evtchn device.\n",
|
|
|
|
+ addr, ioport_base);
|
|
|
|
+ break;
|
2007-03-06 09:12:51 +01:00
|
|
|
+ }
|
2008-03-06 02:36:51 +01:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
static void platform_ioport_map(PCIDevice *pci_dev, int region_num,
|
|
|
|
uint32_t addr, uint32_t size, int type)
|
|
|
|
{
|
|
|
|
- /* nothing yet */
|
|
|
|
+ ioport_base = addr;
|
|
|
|
+
|
|
|
|
+ register_ioport_write(addr, 16, 4, platform_ioport_write, NULL);
|
2007-03-06 09:12:51 +01:00
|
|
|
}
|
|
|
|
|
2007-12-20 16:46:41 +01:00
|
|
|
static uint32_t platform_mmio_read(void *opaque, target_phys_addr_t addr)
|
2008-07-19 01:04:37 +02:00
|
|
|
Index: xen-3.3.0-testing/tools/ioemu/vl.c
|
2007-04-26 01:53:07 +02:00
|
|
|
===================================================================
|
2008-07-19 01:04:37 +02:00
|
|
|
--- xen-3.3.0-testing.orig/tools/ioemu/vl.c
|
|
|
|
+++ xen-3.3.0-testing/tools/ioemu/vl.c
|
|
|
|
@@ -217,6 +217,20 @@ extern int domid;
|
|
|
|
|
|
|
|
PCI_EMULATION_INFO *PciEmulationInfoHead = NULL;
|
2007-03-06 09:12:51 +01:00
|
|
|
|
|
|
|
+typedef struct IOHandlerRecord {
|
|
|
|
+ int fd;
|
|
|
|
+ IOCanRWHandler *fd_read_poll;
|
|
|
|
+ IOHandler *fd_read;
|
|
|
|
+ IOHandler *fd_write;
|
2008-03-06 02:36:51 +01:00
|
|
|
+ int deleted;
|
2007-03-06 09:12:51 +01:00
|
|
|
+ void *opaque;
|
|
|
|
+ /* temporary data */
|
|
|
|
+ struct pollfd *ufd;
|
|
|
|
+ struct IOHandlerRecord *next;
|
|
|
|
+} IOHandlerRecord;
|
|
|
|
+
|
|
|
|
+static IOHandlerRecord *first_io_handler;
|
|
|
|
+
|
2007-12-20 16:46:41 +01:00
|
|
|
/***********************************************************/
|
|
|
|
/* x86 ISA bus support */
|
2007-03-06 09:12:51 +01:00
|
|
|
|
2008-07-19 01:04:37 +02:00
|
|
|
@@ -3449,6 +3463,7 @@ void net_slirp_smb(const char *exported_
|
2007-03-06 09:12:51 +01:00
|
|
|
typedef struct TAPState {
|
|
|
|
VLANClientState *vc;
|
|
|
|
int fd;
|
|
|
|
+ struct TAPState *next;
|
|
|
|
} TAPState;
|
|
|
|
|
|
|
|
static void tap_receive(void *opaque, const uint8_t *buf, int size)
|
2008-07-19 01:04:37 +02:00
|
|
|
@@ -3476,6 +3491,36 @@ static void tap_send(void *opaque)
|
2007-03-06 09:12:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+static TAPState *head_net_tap;
|
|
|
|
+
|
|
|
|
+void net_tap_shutdown_all(void)
|
|
|
|
+{
|
|
|
|
+ struct IOHandlerRecord **pioh, *ioh;
|
|
|
|
+
|
|
|
|
+ while (head_net_tap) {
|
|
|
|
+ pioh = &first_io_handler;
|
|
|
|
+ for (;;) {
|
|
|
|
+ ioh = *pioh;
|
|
|
|
+ if (ioh == NULL)
|
|
|
|
+ break;
|
|
|
|
+ if (ioh->fd == head_net_tap->fd) {
|
|
|
|
+ *pioh = ioh->next;
|
|
|
|
+ qemu_free(ioh);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ pioh = &ioh->next;
|
|
|
|
+ }
|
|
|
|
+ if (!ioh)
|
|
|
|
+ fprintf(stderr,
|
|
|
|
+ "warning: can't find iohandler for %d to close it properly.\n",
|
|
|
|
+ head_net_tap->fd);
|
|
|
|
+ close(head_net_tap->fd);
|
|
|
|
+ head_net_tap = head_net_tap->next;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
/* fd support */
|
|
|
|
|
|
|
|
static TAPState *net_tap_fd_init(VLANState *vlan, int fd)
|
2008-07-19 01:04:37 +02:00
|
|
|
@@ -3487,6 +3532,8 @@ static TAPState *net_tap_fd_init(VLANSta
|
2007-03-06 09:12:51 +01:00
|
|
|
return NULL;
|
|
|
|
s->fd = fd;
|
|
|
|
s->vc = qemu_new_vlan_client(vlan, tap_receive, NULL, s);
|
|
|
|
+ s->next = head_net_tap;
|
|
|
|
+ head_net_tap = s;
|
|
|
|
qemu_set_fd_handler(s->fd, tap_send, NULL, s);
|
|
|
|
snprintf(s->vc->info_str, sizeof(s->vc->info_str), "tap: fd=%d", fd);
|
|
|
|
return s;
|
2008-07-19 01:04:37 +02:00
|
|
|
@@ -4500,20 +4547,6 @@ void dumb_display_init(DisplayState *ds)
|
2007-03-06 09:12:51 +01:00
|
|
|
|
|
|
|
#define MAX_IO_HANDLERS 64
|
|
|
|
|
|
|
|
-typedef struct IOHandlerRecord {
|
|
|
|
- int fd;
|
|
|
|
- IOCanRWHandler *fd_read_poll;
|
|
|
|
- IOHandler *fd_read;
|
|
|
|
- IOHandler *fd_write;
|
2007-12-20 16:46:41 +01:00
|
|
|
- int deleted;
|
2007-03-06 09:12:51 +01:00
|
|
|
- void *opaque;
|
|
|
|
- /* temporary data */
|
|
|
|
- struct pollfd *ufd;
|
|
|
|
- struct IOHandlerRecord *next;
|
|
|
|
-} IOHandlerRecord;
|
|
|
|
-
|
|
|
|
-static IOHandlerRecord *first_io_handler;
|
|
|
|
-
|
|
|
|
/* XXX: fd_read_poll should be suppressed, but an API change is
|
|
|
|
necessary in the character devices to suppress fd_can_read(). */
|
|
|
|
int qemu_set_fd_handler2(int fd,
|
2008-07-19 01:04:37 +02:00
|
|
|
Index: xen-3.3.0-testing/tools/ioemu/vl.h
|
2007-04-26 01:53:07 +02:00
|
|
|
===================================================================
|
2008-07-19 01:04:37 +02:00
|
|
|
--- xen-3.3.0-testing.orig/tools/ioemu/vl.h
|
|
|
|
+++ xen-3.3.0-testing/tools/ioemu/vl.h
|
|
|
|
@@ -1578,6 +1578,8 @@ void kqemu_record_dump(void);
|
2007-03-06 09:12:51 +01:00
|
|
|
extern char domain_name[];
|
|
|
|
|
|
|
|
void destroy_hvm_domain(void);
|
|
|
|
+void net_tap_shutdown_all(void);
|
|
|
|
+void pci_unplug_netifs(void);
|
|
|
|
|
2007-12-20 16:46:41 +01:00
|
|
|
#ifdef __ia64__
|
|
|
|
static inline void xc_domain_shutdown_hook(int xc_handle, uint32_t domid)
|