- more config options

- bootdevice, iscsi, virtio-scsi fixes
 - build system patches for MinGW and config-devices.mak
 - qemu_mutex_lock_iothread deadlock fixes
 - another tiny patch from the record/replay series
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQEcBAABAgAGBQJU9DRyAAoJEL/70l94x66D5ZkH/2SPp4rrLIgotyzHTIaMvi+2
 0gB7Bks9cDisFyiSgr6dqLp9CV1XMlv/NZl+z+H/7og96qhBWjAKVpG1J/En55bS
 vanFeWGYjINuQLnhC3pqBi2kmEkzBQSIMJZt9WnDydfQj/6Wgcr6iabOpd8eTjTz
 rqE/UcV2L1baFPLy/Wky2vg/a5Ug2rj+fqvjRdFB/Zx8yDYLcKYJlI8utSQexamE
 tUcxr/AqxNOoe6WZD7CCVNmHMHvajoOhWnVY4EgHDg8L3nNSgvDF3AjYfntU6A2y
 HjkS0ktvQK666oNo+ORRBzLe3s9nCfB1dMK2ZiKKyFfyuYD50d2N3oHKSAIsEJo=
 =AQjO
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging

- more config options
- bootdevice, iscsi, virtio-scsi fixes
- build system patches for MinGW and config-devices.mak
- qemu_mutex_lock_iothread deadlock fixes
- another tiny patch from the record/replay series

# gpg: Signature made Mon Mar  2 09:59:14 2015 GMT using RSA key ID 78C7AE83
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>"
# gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
#      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83

* remotes/bonzini/tags/for-upstream:
  cpus: be more paranoid in avoiding deadlocks
  cpus: fix deadlock and segfault in qemu_mutex_lock_iothread
  virtio-scsi: Allocate op blocker reason before blocking
  Makefile.target: binary depends on config-devices
  Makefile: don't silence mak file test with V=1
  Makefile: fix up parallel building under MSYS+MinGW
  iscsi: Handle write protected case in reopen
  Give ivshmem its own config option
  Create specific config option for "platform-bus"
  Add specific config options for PCI-E bridges
  bootdevice: fix segment fault when booting guest with '-kernel' and '-initrd'
  timer: replace time() with QEMU_CLOCK_HOST
  virtio-scsi-dataplane: Call blk_set_aio_context within BQL
  block: Forbid bdrv_set_aio_context outside BQL
  scsi: give device a parent before setting properties

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
master
Peter Maydell 2015-03-03 12:07:47 +00:00
commit 3180aadb1f
20 changed files with 81 additions and 48 deletions

View File

@ -109,8 +109,8 @@ endif
-include $(SUBDIR_DEVICES_MAK_DEP) -include $(SUBDIR_DEVICES_MAK_DEP)
%/config-devices.mak: default-configs/%.mak %/config-devices.mak: default-configs/%.mak
$(call quiet-command,$(SHELL) $(SRC_PATH)/scripts/make_device_config.sh $@ $<, " GEN $@") $(call quiet-command,$(SHELL) $(SRC_PATH)/scripts/make_device_config.sh $@.tmp $<, " GEN $@.tmp")
@if test -f $@; then \ $(call quiet-command, if test -f $@; then \
if cmp -s $@.old $@; then \ if cmp -s $@.old $@; then \
mv $@.tmp $@; \ mv $@.tmp $@; \
cp -p $@ $@.old; \ cp -p $@ $@.old; \
@ -126,7 +126,7 @@ endif
else \ else \
mv $@.tmp $@; \ mv $@.tmp $@; \
cp -p $@ $@.old; \ cp -p $@ $@.old; \
fi fi, " GEN $@");
defconfig: defconfig:
rm -f config-all-devices.mak $(SUBDIR_DEVICES_MAK) rm -f config-all-devices.mak $(SUBDIR_DEVICES_MAK)
@ -197,9 +197,9 @@ ALL_SUBDIRS=$(TARGET_DIRS) $(patsubst %,pc-bios/%, $(ROMS))
recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES) recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES)
$(BUILD_DIR)/version.o: $(SRC_PATH)/version.rc $(BUILD_DIR)/config-host.h | $(BUILD_DIR)/version.lo $(BUILD_DIR)/version.o: $(SRC_PATH)/version.rc config-host.h | $(BUILD_DIR)/version.lo
$(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<," RC version.o") $(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<," RC version.o")
$(BUILD_DIR)/version.lo: $(SRC_PATH)/version.rc $(BUILD_DIR)/config-host.h $(BUILD_DIR)/version.lo: $(SRC_PATH)/version.rc config-host.h
$(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<," RC version.lo") $(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<," RC version.lo")
Makefile: $(version-obj-y) $(version-lobj-y) Makefile: $(version-obj-y) $(version-lobj-y)

View File

@ -175,9 +175,11 @@ all-obj-y += $(common-obj-y)
all-obj-y += $(target-obj-y) all-obj-y += $(target-obj-y)
all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y)
$(QEMU_PROG_BUILD): config-devices.mak
# build either PROG or PROGW # build either PROG or PROGW
$(QEMU_PROG_BUILD): $(all-obj-y) ../libqemuutil.a ../libqemustub.a $(QEMU_PROG_BUILD): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
$(call LINK,$^) $(call LINK, $(filter-out %.mak, $^))
gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh
$(call quiet-command,rm -f $@ && $(SHELL) $(SRC_PATH)/scripts/feature_to_c.sh $@ $(TARGET_XML_FILES)," GEN $(TARGET_DIR)$@") $(call quiet-command,rm -f $@ && $(SHELL) $(SRC_PATH)/scripts/feature_to_c.sh $@ $(TARGET_XML_FILES)," GEN $(TARGET_DIR)$@")

View File

@ -65,6 +65,7 @@ typedef struct IscsiLun {
unsigned long *allocationmap; unsigned long *allocationmap;
int cluster_sectors; int cluster_sectors;
bool use_16_for_rw; bool use_16_for_rw;
bool write_protected;
} IscsiLun; } IscsiLun;
typedef struct IscsiTask { typedef struct IscsiTask {
@ -1268,10 +1269,6 @@ out:
/* /*
* We support iscsi url's on the form * We support iscsi url's on the form
* iscsi://[<username>%<password>@]<host>[:<port>]/<targetname>/<lun> * iscsi://[<username>%<password>@]<host>[:<port>]/<targetname>/<lun>
*
* Note: flags are currently not used by iscsi_open. If this function
* is changed such that flags are used, please examine iscsi_reopen_prepare()
* to see if needs to be changed as well.
*/ */
static int iscsi_open(BlockDriverState *bs, QDict *options, int flags, static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp) Error **errp)
@ -1385,9 +1382,10 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
scsi_free_scsi_task(task); scsi_free_scsi_task(task);
task = NULL; task = NULL;
iscsilun->write_protected = iscsi_is_write_protected(iscsilun);
/* Check the write protect flag of the LUN if we want to write */ /* Check the write protect flag of the LUN if we want to write */
if (iscsilun->type == TYPE_DISK && (flags & BDRV_O_RDWR) && if (iscsilun->type == TYPE_DISK && (flags & BDRV_O_RDWR) &&
iscsi_is_write_protected(iscsilun)) { iscsilun->write_protected) {
error_setg(errp, "Cannot open a write protected LUN as read-write"); error_setg(errp, "Cannot open a write protected LUN as read-write");
ret = -EACCES; ret = -EACCES;
goto out; goto out;
@ -1541,13 +1539,17 @@ static void iscsi_refresh_limits(BlockDriverState *bs, Error **errp)
sector_limits_lun2qemu(iscsilun->bl.opt_xfer_len, iscsilun); sector_limits_lun2qemu(iscsilun->bl.opt_xfer_len, iscsilun);
} }
/* Since iscsi_open() ignores bdrv_flags, there is nothing to do here in /* Note that this will not re-establish a connection with an iSCSI target - it
* prepare. Note that this will not re-establish a connection with an iSCSI * is effectively a NOP. */
* target - it is effectively a NOP. */
static int iscsi_reopen_prepare(BDRVReopenState *state, static int iscsi_reopen_prepare(BDRVReopenState *state,
BlockReopenQueue *queue, Error **errp) BlockReopenQueue *queue, Error **errp)
{ {
/* NOP */ IscsiLun *iscsilun = state->bs->opaque;
if (state->flags & BDRV_O_RDWR && iscsilun->write_protected) {
error_setg(errp, "Cannot open a write protected LUN as read-write");
return -EACCES;
}
return 0; return 0;
} }

View File

@ -221,10 +221,15 @@ char *get_boot_devices_list(size_t *size, bool ignore_suffixes)
} }
if (!ignore_suffixes) { if (!ignore_suffixes) {
d = qdev_get_own_fw_dev_path_from_handler(i->dev->parent_bus, i->dev); if (i->dev) {
if (d) { d = qdev_get_own_fw_dev_path_from_handler(i->dev->parent_bus,
assert(!i->suffix); i->dev);
suffix = d; if (d) {
assert(!i->suffix);
suffix = d;
} else {
suffix = g_strdup(i->suffix);
}
} else { } else {
suffix = g_strdup(i->suffix); suffix = g_strdup(i->suffix);
} }

12
cpus.c
View File

@ -778,7 +778,7 @@ static void qemu_tcg_init_cpu_signals(void)
static QemuMutex qemu_global_mutex; static QemuMutex qemu_global_mutex;
static QemuCond qemu_io_proceeded_cond; static QemuCond qemu_io_proceeded_cond;
static bool iothread_requesting_mutex; static unsigned iothread_requesting_mutex;
static QemuThread io_thread; static QemuThread io_thread;
@ -1025,6 +1025,9 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
} }
} }
/* process any pending work */
exit_request = 1;
while (1) { while (1) {
tcg_exec_all(); tcg_exec_all();
@ -1115,15 +1118,16 @@ bool qemu_in_vcpu_thread(void)
void qemu_mutex_lock_iothread(void) void qemu_mutex_lock_iothread(void)
{ {
if (!tcg_enabled()) { atomic_inc(&iothread_requesting_mutex);
if (!tcg_enabled() || !first_cpu) {
qemu_mutex_lock(&qemu_global_mutex); qemu_mutex_lock(&qemu_global_mutex);
atomic_dec(&iothread_requesting_mutex);
} else { } else {
iothread_requesting_mutex = true;
if (qemu_mutex_trylock(&qemu_global_mutex)) { if (qemu_mutex_trylock(&qemu_global_mutex)) {
qemu_cpu_kick_thread(first_cpu); qemu_cpu_kick_thread(first_cpu);
qemu_mutex_lock(&qemu_global_mutex); qemu_mutex_lock(&qemu_global_mutex);
} }
iothread_requesting_mutex = false; atomic_dec(&iothread_requesting_mutex);
qemu_cond_broadcast(&qemu_io_proceeded_cond); qemu_cond_broadcast(&qemu_io_proceeded_cond);
} }
} }

View File

@ -34,6 +34,7 @@ CONFIG_PFLASH_CFI02=y
CONFIG_MICRODRIVE=y CONFIG_MICRODRIVE=y
CONFIG_USB_MUSB=y CONFIG_USB_MUSB=y
CONFIG_USB_EHCI_SYSBUS=y CONFIG_USB_EHCI_SYSBUS=y
CONFIG_PLATFORM_BUS=y
CONFIG_ARM11MPCORE=y CONFIG_ARM11MPCORE=y
CONFIG_A9MPCORE=y CONFIG_A9MPCORE=y
@ -91,3 +92,7 @@ CONFIG_INTEGRATOR_DEBUG=y
CONFIG_ALLWINNER_A10_PIT=y CONFIG_ALLWINNER_A10_PIT=y
CONFIG_ALLWINNER_A10_PIC=y CONFIG_ALLWINNER_A10_PIC=y
CONFIG_ALLWINNER_A10=y CONFIG_ALLWINNER_A10=y
CONFIG_XIO3130=y
CONFIG_IOH3420=y
CONFIG_I82801B11=y

View File

@ -43,3 +43,6 @@ CONFIG_IOAPIC=y
CONFIG_ICC_BUS=y CONFIG_ICC_BUS=y
CONFIG_PVPANIC=y CONFIG_PVPANIC=y
CONFIG_MEM_HOTPLUG=y CONFIG_MEM_HOTPLUG=y
CONFIG_XIO3130=y
CONFIG_IOH3420=y
CONFIG_I82801B11=y

View File

@ -35,3 +35,4 @@ CONFIG_SDHCI=y
CONFIG_EDU=y CONFIG_EDU=y
CONFIG_VGA=y CONFIG_VGA=y
CONFIG_VGA_PCI=y CONFIG_VGA_PCI=y
CONFIG_IVSHMEM=$(CONFIG_KVM)

View File

@ -43,6 +43,7 @@ CONFIG_PREP=y
CONFIG_MAC=y CONFIG_MAC=y
CONFIG_E500=y CONFIG_E500=y
CONFIG_OPENPIC_KVM=$(and $(CONFIG_E500),$(CONFIG_KVM)) CONFIG_OPENPIC_KVM=$(and $(CONFIG_E500),$(CONFIG_KVM))
CONFIG_PLATFORM_BUS=y
CONFIG_ETSEC=y CONFIG_ETSEC=y
CONFIG_LIBDECNUMBER=y CONFIG_LIBDECNUMBER=y
# For PReP # For PReP

View File

@ -44,6 +44,7 @@ CONFIG_PREP=y
CONFIG_MAC=y CONFIG_MAC=y
CONFIG_E500=y CONFIG_E500=y
CONFIG_OPENPIC_KVM=$(and $(CONFIG_E500),$(CONFIG_KVM)) CONFIG_OPENPIC_KVM=$(and $(CONFIG_E500),$(CONFIG_KVM))
CONFIG_PLATFORM_BUS=y
CONFIG_ETSEC=y CONFIG_ETSEC=y
CONFIG_LIBDECNUMBER=y CONFIG_LIBDECNUMBER=y
# For pSeries # For pSeries

View File

@ -43,3 +43,6 @@ CONFIG_IOAPIC=y
CONFIG_ICC_BUS=y CONFIG_ICC_BUS=y
CONFIG_PVPANIC=y CONFIG_PVPANIC=y
CONFIG_MEM_HOTPLUG=y CONFIG_MEM_HOTPLUG=y
CONFIG_XIO3130=y
CONFIG_IOH3420=y
CONFIG_I82801B11=y

View File

@ -14,4 +14,4 @@ common-obj-$(CONFIG_SOFTMMU) += machine.o
common-obj-$(CONFIG_SOFTMMU) += null-machine.o common-obj-$(CONFIG_SOFTMMU) += null-machine.o
common-obj-$(CONFIG_SOFTMMU) += loader.o common-obj-$(CONFIG_SOFTMMU) += loader.o
common-obj-$(CONFIG_SOFTMMU) += qdev-properties-system.o common-obj-$(CONFIG_SOFTMMU) += qdev-properties-system.o
common-obj-$(CONFIG_SOFTMMU) += platform-bus.o common-obj-$(CONFIG_PLATFORM_BUS) += platform-bus.o

View File

@ -19,9 +19,7 @@ common-obj-$(CONFIG_PUV3) += puv3_pm.o
common-obj-$(CONFIG_MACIO) += macio/ common-obj-$(CONFIG_MACIO) += macio/
ifeq ($(CONFIG_PCI), y) obj-$(CONFIG_IVSHMEM) += ivshmem.o
obj-$(CONFIG_KVM) += ivshmem.o
endif
obj-$(CONFIG_REALVIEW) += arm_sysctl.o obj-$(CONFIG_REALVIEW) += arm_sysctl.o
obj-$(CONFIG_NSERIES) += cbus.o obj-$(CONFIG_NSERIES) += cbus.o

View File

@ -1,5 +1,6 @@
common-obj-y += pci_bridge_dev.o common-obj-y += pci_bridge_dev.o
common-obj-y += ioh3420.o xio3130_upstream.o xio3130_downstream.o common-obj-$(CONFIG_XIO3130) += xio3130_upstream.o xio3130_downstream.o
common-obj-y += i82801b11.o common-obj-$(CONFIG_IOH3420) += ioh3420.o
common-obj-$(CONFIG_I82801B11) += i82801b11.o
# NewWorld PowerMac # NewWorld PowerMac
common-obj-$(CONFIG_DEC_PCI) += dec.o common-obj-$(CONFIG_DEC_PCI) += dec.o

View File

@ -221,11 +221,16 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
const char *serial, Error **errp) const char *serial, Error **errp)
{ {
const char *driver; const char *driver;
char *name;
DeviceState *dev; DeviceState *dev;
Error *err = NULL; Error *err = NULL;
driver = blk_is_sg(blk) ? "scsi-generic" : "scsi-disk"; driver = blk_is_sg(blk) ? "scsi-generic" : "scsi-disk";
dev = qdev_create(&bus->qbus, driver); dev = qdev_create(&bus->qbus, driver);
name = g_strdup_printf("legacy[%d]", unit);
object_property_add_child(OBJECT(bus), name, OBJECT(dev), NULL);
g_free(name);
qdev_prop_set_uint32(dev, "scsi-id", unit); qdev_prop_set_uint32(dev, "scsi-id", unit);
if (bootindex >= 0) { if (bootindex >= 0) {
object_property_set_int(OBJECT(dev), bootindex, "bootindex", object_property_set_int(OBJECT(dev), bootindex, "bootindex",

View File

@ -211,8 +211,6 @@ void virtio_scsi_dataplane_start(VirtIOSCSI *s)
s->dataplane_starting = true; s->dataplane_starting = true;
assert(!s->blocker);
error_setg(&s->blocker, "block device is in use by data plane");
/* Set up guest notifier (irq) */ /* Set up guest notifier (irq) */
rc = k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, true); rc = k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, true);
if (rc != 0) { if (rc != 0) {
@ -279,8 +277,6 @@ void virtio_scsi_dataplane_stop(VirtIOSCSI *s)
if (!s->dataplane_started || s->dataplane_stopping) { if (!s->dataplane_started || s->dataplane_stopping) {
return; return;
} }
error_free(s->blocker);
s->blocker = NULL;
s->dataplane_stopping = true; s->dataplane_stopping = true;
assert(s->ctx == iothread_get_aio_context(vs->conf.iothread)); assert(s->ctx == iothread_get_aio_context(vs->conf.iothread));

View File

@ -254,10 +254,8 @@ static int virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req)
int target; int target;
int ret = 0; int ret = 0;
if (s->dataplane_started && blk_get_aio_context(d->conf.blk) != s->ctx) { if (s->dataplane_started) {
aio_context_acquire(s->ctx); assert(blk_get_aio_context(d->conf.blk) == s->ctx);
blk_set_aio_context(d->conf.blk, s->ctx);
aio_context_release(s->ctx);
} }
/* Here VIRTIO_SCSI_S_OK means "FUNCTION COMPLETE". */ /* Here VIRTIO_SCSI_S_OK means "FUNCTION COMPLETE". */
req->resp.tmf.response = VIRTIO_SCSI_S_OK; req->resp.tmf.response = VIRTIO_SCSI_S_OK;
@ -540,10 +538,8 @@ bool virtio_scsi_handle_cmd_req_prepare(VirtIOSCSI *s, VirtIOSCSIReq *req)
virtio_scsi_complete_cmd_req(req); virtio_scsi_complete_cmd_req(req);
return false; return false;
} }
if (s->dataplane_started && blk_get_aio_context(d->conf.blk) != s->ctx) { if (s->dataplane_started) {
aio_context_acquire(s->ctx); assert(blk_get_aio_context(d->conf.blk) == s->ctx);
blk_set_aio_context(d->conf.blk, s->ctx);
aio_context_release(s->ctx);
} }
req->sreq = scsi_req_new(d, req->req.cmd.tag, req->sreq = scsi_req_new(d, req->req.cmd.tag,
virtio_scsi_get_lun(req->req.cmd.lun), virtio_scsi_get_lun(req->req.cmd.lun),
@ -767,6 +763,9 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev,
return; return;
} }
blk_op_block_all(sd->conf.blk, s->blocker); blk_op_block_all(sd->conf.blk, s->blocker);
aio_context_acquire(s->ctx);
blk_set_aio_context(sd->conf.blk, s->ctx);
aio_context_release(s->ctx);
} }
if ((vdev->guest_features >> VIRTIO_SCSI_F_HOTPLUG) & 1) { if ((vdev->guest_features >> VIRTIO_SCSI_F_HOTPLUG) & 1) {
@ -904,6 +903,8 @@ static void virtio_scsi_device_realize(DeviceState *dev, Error **errp)
virtio_scsi_save, virtio_scsi_load, s); virtio_scsi_save, virtio_scsi_load, s);
s->migration_state_notifier.notify = virtio_scsi_migration_state_changed; s->migration_state_notifier.notify = virtio_scsi_migration_state_changed;
add_migration_state_change_notifier(&s->migration_state_notifier); add_migration_state_change_notifier(&s->migration_state_notifier);
error_setg(&s->blocker, "block device is in use by data plane");
} }
static void virtio_scsi_instance_init(Object *obj) static void virtio_scsi_instance_init(Object *obj)
@ -929,6 +930,8 @@ static void virtio_scsi_device_unrealize(DeviceState *dev, Error **errp)
{ {
VirtIOSCSI *s = VIRTIO_SCSI(dev); VirtIOSCSI *s = VIRTIO_SCSI(dev);
error_free(s->blocker);
unregister_savevm(dev, "virtio-scsi", s); unregister_savevm(dev, "virtio-scsi", s);
remove_migration_state_change_notifier(&s->migration_state_notifier); remove_migration_state_change_notifier(&s->migration_state_notifier);

View File

@ -547,8 +547,7 @@ AioContext *bdrv_get_aio_context(BlockDriverState *bs);
* Changes the #AioContext used for fd handlers, timers, and BHs by this * Changes the #AioContext used for fd handlers, timers, and BHs by this
* BlockDriverState and all its children. * BlockDriverState and all its children.
* *
* This function must be called from the old #AioContext or with a lock held so * This function must be called with iothread lock held.
* the old #AioContext is not executing.
*/ */
void bdrv_set_aio_context(BlockDriverState *bs, AioContext *new_context); void bdrv_set_aio_context(BlockDriverState *bs, AioContext *new_context);

View File

@ -2,7 +2,7 @@
# Construct a target device config file from a default, pulling in any # Construct a target device config file from a default, pulling in any
# files from include directives. # files from include directives.
dest=$1.tmp dest=$1
dep=`dirname $1`-`basename $1`.d dep=`dirname $1`-`basename $1`.d
src=$2 src=$2
src_dir=`dirname $src` src_dir=`dirname $src`

12
vl.c
View File

@ -707,13 +707,17 @@ void vm_start(void)
/***********************************************************/ /***********************************************************/
/* real time host monotonic timer */ /* real time host monotonic timer */
static time_t qemu_time(void)
{
return qemu_clock_get_ms(QEMU_CLOCK_HOST) / 1000;
}
/***********************************************************/ /***********************************************************/
/* host time/date access */ /* host time/date access */
void qemu_get_timedate(struct tm *tm, int offset) void qemu_get_timedate(struct tm *tm, int offset)
{ {
time_t ti; time_t ti = qemu_time();
time(&ti);
ti += offset; ti += offset;
if (rtc_date_offset == -1) { if (rtc_date_offset == -1) {
if (rtc_utc) if (rtc_utc)
@ -741,7 +745,7 @@ int qemu_timedate_diff(struct tm *tm)
else else
seconds = mktimegm(tm) + rtc_date_offset; seconds = mktimegm(tm) + rtc_date_offset;
return seconds - time(NULL); return seconds - qemu_time();
} }
static void configure_rtc_date_offset(const char *startdate, int legacy) static void configure_rtc_date_offset(const char *startdate, int legacy)
@ -779,7 +783,7 @@ static void configure_rtc_date_offset(const char *startdate, int legacy)
"'2006-06-17T16:01:21' or '2006-06-17'\n"); "'2006-06-17T16:01:21' or '2006-06-17'\n");
exit(1); exit(1);
} }
rtc_date_offset = time(NULL) - rtc_start_date; rtc_date_offset = qemu_time() - rtc_start_date;
} }
} }