ia64/xen-unstable

changeset 10950:955f02563a13

[qemu patches] Update patches for changeset 10921:4c2fab8f8c34.

Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
author chris@kneesaa.uk.xensource.com
date Thu Aug 03 18:34:03 2006 +0100 (2006-08-03)
parents 4c2fab8f8c34
children 155385a02d0b
files tools/ioemu/patches/series tools/ioemu/patches/xenstore-block-device-config
line diff
     1.1 --- a/tools/ioemu/patches/series	Thu Aug 03 18:28:29 2006 +0100
     1.2 +++ b/tools/ioemu/patches/series	Thu Aug 03 18:34:03 2006 +0100
     1.3 @@ -35,3 +35,4 @@ vnc-fixes
     1.4  vnc-start-vncviewer
     1.5  vnc-title-domain-name
     1.6  vnc-access-monitor-vt
     1.7 +xenstore-block-device-config
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tools/ioemu/patches/xenstore-block-device-config	Thu Aug 03 18:34:03 2006 +0100
     2.3 @@ -0,0 +1,467 @@
     2.4 +Index: ioemu/Makefile.target
     2.5 +===================================================================
     2.6 +--- ioemu.orig/Makefile.target	2006-08-03 17:57:38.861210420 +0100
     2.7 ++++ ioemu/Makefile.target	2006-08-03 17:58:02.317549891 +0100
     2.8 +@@ -336,6 +336,7 @@
     2.9 + VL_OBJS+= fdc.o mc146818rtc.o serial.o pc.o
    2.10 + VL_OBJS+= cirrus_vga.o mixeng.o parallel.o
    2.11 + VL_OBJS+= piix4acpi.o
    2.12 ++VL_OBJS+= xenstore.o
    2.13 + DEFINES += -DHAS_AUDIO
    2.14 + endif
    2.15 + ifeq ($(TARGET_BASE_ARCH), ppc)
    2.16 +Index: ioemu/xenstore.c
    2.17 +===================================================================
    2.18 +--- /dev/null	1970-01-01 00:00:00.000000000 +0000
    2.19 ++++ ioemu/xenstore.c	2006-08-03 17:58:02.326548870 +0100
    2.20 +@@ -0,0 +1,187 @@
    2.21 ++/*
    2.22 ++ * This file is subject to the terms and conditions of the GNU General
    2.23 ++ * Public License.  See the file "COPYING" in the main directory of
    2.24 ++ * this archive for more details.
    2.25 ++ *
    2.26 ++ * Copyright (C) 2006 Christian Limpach
    2.27 ++ * Copyright (C) 2006 XenSource Ltd.
    2.28 ++ *
    2.29 ++ */
    2.30 ++
    2.31 ++#include "vl.h"
    2.32 ++#include "block_int.h"
    2.33 ++
    2.34 ++static struct xs_handle *xsh = NULL;
    2.35 ++static char *hd_filename[MAX_DISKS];
    2.36 ++static QEMUTimer *insert_timer = NULL;
    2.37 ++
    2.38 ++static int pasprintf(char **buf, const char *fmt, ...)
    2.39 ++{
    2.40 ++    va_list ap;
    2.41 ++    int ret = 0;
    2.42 ++
    2.43 ++    if (*buf)
    2.44 ++	free(*buf);
    2.45 ++    va_start(ap, fmt);
    2.46 ++    if (vasprintf(buf, fmt, ap) == -1) {
    2.47 ++	buf = NULL;
    2.48 ++	ret = -1;
    2.49 ++    }
    2.50 ++    va_end(ap);
    2.51 ++    return ret;
    2.52 ++}
    2.53 ++
    2.54 ++static void insert_media(void *opaque)
    2.55 ++{
    2.56 ++    int i;
    2.57 ++
    2.58 ++    for (i = 0; i < MAX_DISKS; i++) {
    2.59 ++	if (hd_filename[i]) {
    2.60 ++	    do_change(bs_table[i]->device_name, hd_filename[i]);
    2.61 ++	    free(hd_filename[i]);
    2.62 ++	    hd_filename[i] = NULL;
    2.63 ++	}
    2.64 ++    }
    2.65 ++}
    2.66 ++
    2.67 ++void xenstore_check_new_media_present(int timeout)
    2.68 ++{
    2.69 ++
    2.70 ++    if (insert_timer == NULL)
    2.71 ++	insert_timer = qemu_new_timer(rt_clock, insert_media, NULL);
    2.72 ++    qemu_mod_timer(insert_timer, qemu_get_clock(rt_clock) + timeout);
    2.73 ++}
    2.74 ++
    2.75 ++void xenstore_parse_domain_config(int domid)
    2.76 ++{
    2.77 ++    char **e = NULL;
    2.78 ++    char *buf = NULL, *path;
    2.79 ++    char *bpath = NULL, *dev = NULL, *params = NULL, *type = NULL;
    2.80 ++    int i;
    2.81 ++    unsigned int len, num, hd_index;
    2.82 ++
    2.83 ++    for(i = 0; i < MAX_DISKS; i++)
    2.84 ++        hd_filename[i] = NULL;
    2.85 ++
    2.86 ++    xsh = xs_daemon_open();
    2.87 ++    if (xsh == NULL) {
    2.88 ++	fprintf(logfile, "Could not contact xenstore for domain config\n");
    2.89 ++	return;
    2.90 ++    }
    2.91 ++
    2.92 ++    path = xs_get_domain_path(xsh, domid);
    2.93 ++    if (path == NULL) {
    2.94 ++        fprintf(logfile, "xs_get_domain_path() error\n");
    2.95 ++        goto out;
    2.96 ++    }
    2.97 ++
    2.98 ++    if (pasprintf(&buf, "%s/device/vbd", path) == -1)
    2.99 ++	goto out;
   2.100 ++
   2.101 ++    e = xs_directory(xsh, XBT_NULL, buf, &num);
   2.102 ++    if (e == NULL)
   2.103 ++	goto out;
   2.104 ++
   2.105 ++    for (i = 0; i < num; i++) {
   2.106 ++	/* read the backend path */
   2.107 ++	if (pasprintf(&buf, "%s/device/vbd/%s/backend", path, e[i]) == -1)
   2.108 ++	    continue;
   2.109 ++	free(bpath);
   2.110 ++        bpath = xs_read(xsh, XBT_NULL, buf, &len);
   2.111 ++	if (bpath == NULL)
   2.112 ++	    continue;
   2.113 ++	/* read the name of the device */
   2.114 ++	if (pasprintf(&buf, "%s/dev", bpath) == -1)
   2.115 ++	    continue;
   2.116 ++	free(dev);
   2.117 ++	dev = xs_read(xsh, XBT_NULL, buf, &len);
   2.118 ++	if (dev == NULL)
   2.119 ++	    continue;
   2.120 ++	if (strncmp(dev, "hd", 2) || strlen(dev) != 3)
   2.121 ++	    continue;
   2.122 ++	hd_index = dev[2] - 'a';
   2.123 ++	if (hd_index > MAX_DISKS)
   2.124 ++	    continue;
   2.125 ++	/* read the type of the device */
   2.126 ++	if (pasprintf(&buf, "%s/device/vbd/%s/device-type", path, e[i]) == -1)
   2.127 ++	    continue;
   2.128 ++	free(type);
   2.129 ++	type = xs_read(xsh, XBT_NULL, buf, &len);
   2.130 ++	/* read params to get the patch of the image -- read it last
   2.131 ++	 * so that we have its path in buf when setting up the
   2.132 ++	 * watch */
   2.133 ++	if (pasprintf(&buf, "%s/params", bpath) == -1)
   2.134 ++	    continue;
   2.135 ++	free(params);
   2.136 ++	params = xs_read(xsh, XBT_NULL, buf, &len);
   2.137 ++	if (params == NULL)
   2.138 ++	    continue;
   2.139 ++	if (params[0]) {
   2.140 ++	    hd_filename[hd_index] = params;	/* strdup() */
   2.141 ++	    params = NULL;		/* don't free params on re-use */
   2.142 ++	}
   2.143 ++	bs_table[hd_index] = bdrv_new(dev);
   2.144 ++	/* check if it is a cdrom */
   2.145 ++	if (type && !strcmp(type, "cdrom")) {
   2.146 ++	    bdrv_set_type_hint(bs_table[hd_index], BDRV_TYPE_CDROM);
   2.147 ++	    xs_watch(xsh, buf, dev);
   2.148 ++	}
   2.149 ++	if (hd_filename[hd_index]) {
   2.150 ++            if (bdrv_open(bs_table[hd_index], hd_filename[hd_index],
   2.151 ++			  0 /* snapshot */) < 0)
   2.152 ++                fprintf(stderr, "qemu: could not open hard disk image '%s'\n",
   2.153 ++                        hd_filename[hd_index]);
   2.154 ++	}
   2.155 ++    }
   2.156 ++
   2.157 ++ out:
   2.158 ++    free(type);
   2.159 ++    free(params);
   2.160 ++    free(dev);
   2.161 ++    free(bpath);
   2.162 ++    free(buf);
   2.163 ++    free(path);
   2.164 ++    free(e);
   2.165 ++    return;
   2.166 ++}
   2.167 ++
   2.168 ++int xenstore_fd(void)
   2.169 ++{
   2.170 ++    if (xsh)
   2.171 ++	return xs_fileno(xsh);
   2.172 ++    return -1;
   2.173 ++}
   2.174 ++
   2.175 ++void xenstore_process_event(void *opaque)
   2.176 ++{
   2.177 ++    char **vec, *image = NULL;
   2.178 ++    unsigned int len, num, hd_index;
   2.179 ++
   2.180 ++    vec = xs_read_watch(xsh, &num);
   2.181 ++    if (!vec)
   2.182 ++	return;
   2.183 ++
   2.184 ++    if (strncmp(vec[XS_WATCH_TOKEN], "hd", 2) ||
   2.185 ++	strlen(vec[XS_WATCH_TOKEN]) != 3)
   2.186 ++	goto out;
   2.187 ++    hd_index = vec[XS_WATCH_TOKEN][2] - 'a';
   2.188 ++    image = xs_read(xsh, XBT_NULL, vec[XS_WATCH_PATH], &len);
   2.189 ++    if (image == NULL || !strcmp(image, bs_table[hd_index]->filename))
   2.190 ++	goto out;		/* gone or identical */
   2.191 ++
   2.192 ++    do_eject(0, vec[XS_WATCH_TOKEN]);
   2.193 ++    bs_table[hd_index]->filename[0] = 0;
   2.194 ++    if (hd_filename[hd_index]) {
   2.195 ++	free(hd_filename[hd_index]);
   2.196 ++	hd_filename[hd_index] = NULL;
   2.197 ++    }
   2.198 ++
   2.199 ++    if (image[0]) {
   2.200 ++	hd_filename[hd_index] = strdup(image);
   2.201 ++	xenstore_check_new_media_present(5000);
   2.202 ++    }
   2.203 ++
   2.204 ++ out:
   2.205 ++    free(image);
   2.206 ++    free(vec);
   2.207 ++}
   2.208 +Index: ioemu/vl.c
   2.209 +===================================================================
   2.210 +--- ioemu.orig/vl.c	2006-08-03 17:57:38.867209740 +0100
   2.211 ++++ ioemu/vl.c	2006-08-03 17:58:02.323549210 +0100
   2.212 +@@ -4709,9 +4709,11 @@
   2.213 +            "Standard options:\n"
   2.214 +            "-M machine      select emulated machine (-M ? for list)\n"
   2.215 +            "-fda/-fdb file  use 'file' as floppy disk 0/1 image\n"
   2.216 ++#ifndef CONFIG_DM
   2.217 +            "-hda/-hdb file  use 'file' as IDE hard disk 0/1 image\n"
   2.218 +            "-hdc/-hdd file  use 'file' as IDE hard disk 2/3 image\n"
   2.219 +            "-cdrom file     use 'file' as IDE cdrom image (cdrom is ide1 master)\n"
   2.220 ++#endif /* !CONFIG_DM */
   2.221 +            "-boot [a|c|d]   boot on floppy (a), hard disk (c) or CD-ROM (d)\n"
   2.222 + 	   "-snapshot       write to temporary files instead of disk image files\n"
   2.223 +            "-m megs         set virtual RAM size to megs MB [default=%d]\n"
   2.224 +@@ -4841,11 +4843,13 @@
   2.225 +     QEMU_OPTION_M,
   2.226 +     QEMU_OPTION_fda,
   2.227 +     QEMU_OPTION_fdb,
   2.228 ++#ifndef CONFIG_DM
   2.229 +     QEMU_OPTION_hda,
   2.230 +     QEMU_OPTION_hdb,
   2.231 +     QEMU_OPTION_hdc,
   2.232 +     QEMU_OPTION_hdd,
   2.233 +     QEMU_OPTION_cdrom,
   2.234 ++#endif /* !CONFIG_DM */
   2.235 +     QEMU_OPTION_boot,
   2.236 +     QEMU_OPTION_snapshot,
   2.237 +     QEMU_OPTION_m,
   2.238 +@@ -4911,11 +4915,13 @@
   2.239 +     { "M", HAS_ARG, QEMU_OPTION_M },
   2.240 +     { "fda", HAS_ARG, QEMU_OPTION_fda },
   2.241 +     { "fdb", HAS_ARG, QEMU_OPTION_fdb },
   2.242 ++#ifndef CONFIG_DM
   2.243 +     { "hda", HAS_ARG, QEMU_OPTION_hda },
   2.244 +     { "hdb", HAS_ARG, QEMU_OPTION_hdb },
   2.245 +     { "hdc", HAS_ARG, QEMU_OPTION_hdc },
   2.246 +     { "hdd", HAS_ARG, QEMU_OPTION_hdd },
   2.247 +     { "cdrom", HAS_ARG, QEMU_OPTION_cdrom },
   2.248 ++#endif /* !CONFIG_DM */
   2.249 +     { "boot", HAS_ARG, QEMU_OPTION_boot },
   2.250 +     { "snapshot", 0, QEMU_OPTION_snapshot },
   2.251 +     { "m", HAS_ARG, QEMU_OPTION_m },
   2.252 +@@ -5250,10 +5256,16 @@
   2.253 + #ifdef CONFIG_GDBSTUB
   2.254 +     int use_gdbstub, gdbstub_port;
   2.255 + #endif
   2.256 +-    int i, cdrom_index;
   2.257 ++    int i;
   2.258 ++#ifndef CONFIG_DM
   2.259 ++    int cdrom_index;
   2.260 ++#endif /* !CONFIG_DM */
   2.261 +     int snapshot, linux_boot;
   2.262 +     const char *initrd_filename;
   2.263 +-    const char *hd_filename[MAX_DISKS], *fd_filename[MAX_FD];
   2.264 ++#ifndef CONFIG_DM
   2.265 ++    const char *hd_filename[MAX_DISKS];
   2.266 ++#endif /* !CONFIG_DM */
   2.267 ++    const char *fd_filename[MAX_FD];
   2.268 +     const char *kernel_filename, *kernel_cmdline;
   2.269 +     DisplayState *ds = &display_state;
   2.270 +     int cyls, heads, secs, translation;
   2.271 +@@ -5288,8 +5300,10 @@
   2.272 +     initrd_filename = NULL;
   2.273 +     for(i = 0; i < MAX_FD; i++)
   2.274 +         fd_filename[i] = NULL;
   2.275 ++#ifndef CONFIG_DM
   2.276 +     for(i = 0; i < MAX_DISKS; i++)
   2.277 +         hd_filename[i] = NULL;
   2.278 ++#endif /* !CONFIG_DM */
   2.279 +     ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
   2.280 +     vga_ram_size = VGA_RAM_SIZE;
   2.281 +     bios_size = BIOS_SIZE;
   2.282 +@@ -5302,11 +5316,13 @@
   2.283 +     vncviewer = 0;
   2.284 +     kernel_filename = NULL;
   2.285 +     kernel_cmdline = "";
   2.286 ++#ifndef CONFIG_DM
   2.287 + #ifdef TARGET_PPC
   2.288 +     cdrom_index = 1;
   2.289 + #else
   2.290 +     cdrom_index = 2;
   2.291 + #endif
   2.292 ++#endif /* !CONFIG_DM */
   2.293 +     cyls = heads = secs = 0;
   2.294 +     translation = BIOS_ATA_TRANSLATION_AUTO;
   2.295 +     pstrcpy(monitor_device, sizeof(monitor_device), "vc");
   2.296 +@@ -5339,7 +5355,11 @@
   2.297 +             break;
   2.298 +         r = argv[optind];
   2.299 +         if (r[0] != '-') {
   2.300 ++#ifndef CONFIG_DM
   2.301 +             hd_filename[0] = argv[optind++];
   2.302 ++#else
   2.303 ++            help();
   2.304 ++#endif /* !CONFIG_DM */
   2.305 +         } else {
   2.306 +             const QEMUOption *popt;
   2.307 + 
   2.308 +@@ -5383,6 +5403,7 @@
   2.309 +             case QEMU_OPTION_initrd:
   2.310 +                 initrd_filename = optarg;
   2.311 +                 break;
   2.312 ++#ifndef CONFIG_DM
   2.313 +             case QEMU_OPTION_hda:
   2.314 +             case QEMU_OPTION_hdb:
   2.315 +             case QEMU_OPTION_hdc:
   2.316 +@@ -5395,6 +5416,7 @@
   2.317 +                         cdrom_index = -1;
   2.318 +                 }
   2.319 +                 break;
   2.320 ++#endif /* !CONFIG_DM */
   2.321 +             case QEMU_OPTION_snapshot:
   2.322 +                 snapshot = 1;
   2.323 +                 break;
   2.324 +@@ -5447,11 +5469,13 @@
   2.325 +             case QEMU_OPTION_append:
   2.326 +                 kernel_cmdline = optarg;
   2.327 +                 break;
   2.328 ++#ifndef CONFIG_DM
   2.329 +             case QEMU_OPTION_cdrom:
   2.330 +                 if (cdrom_index >= 0) {
   2.331 +                     hd_filename[cdrom_index] = optarg;
   2.332 +                 }
   2.333 +                 break;
   2.334 ++#endif /* !CONFIG_DM */
   2.335 +             case QEMU_OPTION_boot:
   2.336 +                 boot_device = optarg[0];
   2.337 +                 if (boot_device != 'a' && 
   2.338 +@@ -5690,12 +5714,18 @@
   2.339 +         }
   2.340 +     }
   2.341 + 
   2.342 ++#ifdef CONFIG_DM
   2.343 ++    bdrv_init();
   2.344 ++    xenstore_parse_domain_config(domid);
   2.345 ++#endif /* CONFIG_DM */
   2.346 ++
   2.347 + #ifdef USE_KQEMU
   2.348 +     if (smp_cpus > 1)
   2.349 +         kqemu_allowed = 0;
   2.350 + #endif
   2.351 +     linux_boot = (kernel_filename != NULL);
   2.352 +         
   2.353 ++#ifndef CONFIG_DM
   2.354 +     if (!linux_boot && 
   2.355 +         hd_filename[0] == '\0' && 
   2.356 +         (cdrom_index >= 0 && hd_filename[cdrom_index] == '\0') &&
   2.357 +@@ -5709,6 +5739,7 @@
   2.358 +         else
   2.359 +             boot_device = 'd';
   2.360 +     }
   2.361 ++#endif /* !CONFIG_DM */
   2.362 + 
   2.363 + #if !defined(CONFIG_SOFTMMU)
   2.364 +     /* must avoid mmap() usage of glibc by setting a buffer "by hand" */
   2.365 +@@ -5848,6 +5879,7 @@
   2.366 + 
   2.367 + #endif /* !CONFIG_DM */
   2.368 + 
   2.369 ++#ifndef CONFIG_DM
   2.370 +     /* we always create the cdrom drive, even if no disk is there */
   2.371 +     bdrv_init();
   2.372 +     if (cdrom_index >= 0) {
   2.373 +@@ -5874,6 +5906,7 @@
   2.374 +             }
   2.375 +         }
   2.376 +     }
   2.377 ++#endif /* !CONFIG_DM */
   2.378 + 
   2.379 +     /* we always create at least one floppy disk */
   2.380 +     fd_table[0] = bdrv_new("fda");
   2.381 +@@ -6009,6 +6042,8 @@
   2.382 + #endif
   2.383 +     init_timers();
   2.384 + 
   2.385 ++    qemu_set_fd_handler(xenstore_fd(), xenstore_process_event, NULL, NULL);
   2.386 ++
   2.387 +     machine->init(ram_size, vga_ram_size, boot_device,
   2.388 +                   ds, fd_filename, snapshot,
   2.389 +                   kernel_filename, kernel_cmdline, initrd_filename,
   2.390 +Index: ioemu/monitor.c
   2.391 +===================================================================
   2.392 +--- ioemu.orig/monitor.c	2006-08-03 17:57:38.864210080 +0100
   2.393 ++++ ioemu/monitor.c	2006-08-03 17:58:02.321549437 +0100
   2.394 +@@ -24,6 +24,7 @@
   2.395 + #include "vl.h"
   2.396 + #include "disas.h"
   2.397 + #include <dirent.h>
   2.398 ++#include "block_int.h"
   2.399 + 
   2.400 + //#define DEBUG
   2.401 + //#define DEBUG_COMPLETION
   2.402 +@@ -328,7 +329,7 @@
   2.403 +     return 0;
   2.404 + }
   2.405 + 
   2.406 +-static void do_eject(int force, const char *filename)
   2.407 ++void do_eject(int force, const char *filename)
   2.408 + {
   2.409 +     BlockDriverState *bs;
   2.410 + 
   2.411 +@@ -340,7 +341,7 @@
   2.412 +     eject_device(bs, force);
   2.413 + }
   2.414 + 
   2.415 +-static void do_change(const char *device, const char *filename)
   2.416 ++void do_change(const char *device, const char *filename)
   2.417 + {
   2.418 +     BlockDriverState *bs;
   2.419 +     int i;
   2.420 +Index: ioemu/block.c
   2.421 +===================================================================
   2.422 +--- ioemu.orig/block.c	2006-08-03 17:57:38.861210420 +0100
   2.423 ++++ ioemu/block.c	2006-08-03 17:58:02.318549777 +0100
   2.424 +@@ -750,6 +750,7 @@
   2.425 + static void raw_close(BlockDriverState *bs)
   2.426 + {
   2.427 +     BDRVRawState *s = bs->opaque;
   2.428 ++    bs->total_sectors = 0;
   2.429 +     close(s->fd);
   2.430 + }
   2.431 + 
   2.432 +Index: ioemu/vl.h
   2.433 +===================================================================
   2.434 +--- ioemu.orig/vl.h	2006-08-03 17:57:38.868209627 +0100
   2.435 ++++ ioemu/vl.h	2006-08-03 17:58:02.324549097 +0100
   2.436 +@@ -1092,6 +1092,8 @@
   2.437 + void term_print_help(void);
   2.438 + void monitor_readline(const char *prompt, int is_password,
   2.439 +                       char *buf, int buf_size);
   2.440 ++void do_eject(int force, const char *filename);
   2.441 ++void do_change(const char *device, const char *filename);
   2.442 + 
   2.443 + /* readline.c */
   2.444 + typedef void ReadLineFunc(void *opaque, const char *str);
   2.445 +@@ -1104,6 +1106,13 @@
   2.446 + void readline_start(const char *prompt, int is_password,
   2.447 +                     ReadLineFunc *readline_func, void *opaque);
   2.448 + 
   2.449 ++/* xenstore.c */
   2.450 ++void xenstore_parse_domain_config(int domid);
   2.451 ++int xenstore_fd(void);
   2.452 ++void xenstore_process_event(void *opaque);
   2.453 ++void xenstore_check_new_media_present(int timeout);
   2.454 ++
   2.455 ++
   2.456 + void kqemu_record_dump(void);
   2.457 + 
   2.458 + extern char domain_name[];
   2.459 +Index: ioemu/hw/ide.c
   2.460 +===================================================================
   2.461 +--- ioemu.orig/hw/ide.c	2006-08-03 17:57:38.863210194 +0100
   2.462 ++++ ioemu/hw/ide.c	2006-08-03 17:58:02.319549664 +0100
   2.463 +@@ -1279,6 +1279,7 @@
   2.464 +         } else {
   2.465 +             ide_atapi_cmd_error(s, SENSE_NOT_READY, 
   2.466 +                                 ASC_MEDIUM_NOT_PRESENT);
   2.467 ++            xenstore_check_new_media_present(1000);
   2.468 +         }
   2.469 +         break;
   2.470 +     case GPCMD_MODE_SENSE_10: