Merge remote-tracking branch 'stefanha/trivial-patches' into staging
* stefanha/trivial-patches: hw/pc.c: Fix converting of ioport_register* to MemoryRegion Replace remaining gmtime, localtime by gmtime_r, localtime_r savevm: Remove MinGW specific code which is no longer needed qga/channel-posix.c: Explicitly include string.h configure: Fix comment (copy+paste bug) readline: avoid memcpy() of overlapping regions Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
commit
fedf2de310
10
block.c
10
block.c
|
@ -3338,11 +3338,7 @@ char *get_human_readable_size(char *buf, int buf_size, int64_t size)
|
||||||
char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn)
|
char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn)
|
||||||
{
|
{
|
||||||
char buf1[128], date_buf[128], clock_buf[128];
|
char buf1[128], date_buf[128], clock_buf[128];
|
||||||
#ifdef _WIN32
|
|
||||||
struct tm *ptm;
|
|
||||||
#else
|
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
#endif
|
|
||||||
time_t ti;
|
time_t ti;
|
||||||
int64_t secs;
|
int64_t secs;
|
||||||
|
|
||||||
|
@ -3352,15 +3348,9 @@ char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn)
|
||||||
"ID", "TAG", "VM SIZE", "DATE", "VM CLOCK");
|
"ID", "TAG", "VM SIZE", "DATE", "VM CLOCK");
|
||||||
} else {
|
} else {
|
||||||
ti = sn->date_sec;
|
ti = sn->date_sec;
|
||||||
#ifdef _WIN32
|
|
||||||
ptm = localtime(&ti);
|
|
||||||
strftime(date_buf, sizeof(date_buf),
|
|
||||||
"%Y-%m-%d %H:%M:%S", ptm);
|
|
||||||
#else
|
|
||||||
localtime_r(&ti, &tm);
|
localtime_r(&ti, &tm);
|
||||||
strftime(date_buf, sizeof(date_buf),
|
strftime(date_buf, sizeof(date_buf),
|
||||||
"%Y-%m-%d %H:%M:%S", &tm);
|
"%Y-%m-%d %H:%M:%S", &tm);
|
||||||
#endif
|
|
||||||
secs = sn->vm_clock_nsec / 1000000000;
|
secs = sn->vm_clock_nsec / 1000000000;
|
||||||
snprintf(clock_buf, sizeof(clock_buf),
|
snprintf(clock_buf, sizeof(clock_buf),
|
||||||
"%02d:%02d:%02d.%03d",
|
"%02d:%02d:%02d.%03d",
|
||||||
|
|
|
@ -529,13 +529,9 @@ static inline uint8_t fat_chksum(const direntry_t* entry)
|
||||||
/* if return_time==0, this returns the fat_date, else the fat_time */
|
/* if return_time==0, this returns the fat_date, else the fat_time */
|
||||||
static uint16_t fat_datetime(time_t time,int return_time) {
|
static uint16_t fat_datetime(time_t time,int return_time) {
|
||||||
struct tm* t;
|
struct tm* t;
|
||||||
#ifdef _WIN32
|
|
||||||
t=localtime(&time); /* this is not thread safe */
|
|
||||||
#else
|
|
||||||
struct tm t1;
|
struct tm t1;
|
||||||
t = &t1;
|
t = &t1;
|
||||||
localtime_r(&time,t);
|
localtime_r(&time,t);
|
||||||
#endif
|
|
||||||
if(return_time)
|
if(return_time)
|
||||||
return cpu_to_le16((t->tm_sec/2)|(t->tm_min<<5)|(t->tm_hour<<11));
|
return cpu_to_le16((t->tm_sec/2)|(t->tm_min<<5)|(t->tm_hour<<11));
|
||||||
return cpu_to_le16((t->tm_mday)|((t->tm_mon+1)<<5)|((t->tm_year-80)<<9));
|
return cpu_to_le16((t->tm_mday)|((t->tm_mon+1)<<5)|((t->tm_year-80)<<9));
|
||||||
|
|
|
@ -2705,7 +2705,7 @@ if compile_prog "" "" ; then
|
||||||
byteswap_h=yes
|
byteswap_h=yes
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Search for bswap_32 function
|
# Search for bswap32 function
|
||||||
bswap_h=no
|
bswap_h=no
|
||||||
cat > $TMPC << EOF
|
cat > $TMPC << EOF
|
||||||
#include <sys/endian.h>
|
#include <sys/endian.h>
|
||||||
|
|
|
@ -2830,7 +2830,7 @@ static void omap_rtc_tick(void *opaque)
|
||||||
s->round = 0;
|
s->round = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&s->current_tm, localtime(&s->ti), sizeof(s->current_tm));
|
localtime_r(&s->ti, &s->current_tm);
|
||||||
|
|
||||||
if ((s->interrupts & 0x08) && s->ti == s->alarm_ti) {
|
if ((s->interrupts & 0x08) && s->ti == s->alarm_ti) {
|
||||||
s->status |= 0x40;
|
s->status |= 0x40;
|
||||||
|
|
12
hw/pc.c
12
hw/pc.c
|
@ -103,6 +103,11 @@ static void ioport80_write(void *opaque, hwaddr addr, uint64_t data,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint64_t ioport80_read(void *opaque, hwaddr addr, unsigned size)
|
||||||
|
{
|
||||||
|
return 0xffffffffffffffff;
|
||||||
|
}
|
||||||
|
|
||||||
/* MSDOS compatibility mode FPU exception support */
|
/* MSDOS compatibility mode FPU exception support */
|
||||||
static qemu_irq ferr_irq;
|
static qemu_irq ferr_irq;
|
||||||
|
|
||||||
|
@ -123,6 +128,11 @@ static void ioportF0_write(void *opaque, hwaddr addr, uint64_t data,
|
||||||
qemu_irq_lower(ferr_irq);
|
qemu_irq_lower(ferr_irq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint64_t ioportF0_read(void *opaque, hwaddr addr, unsigned size)
|
||||||
|
{
|
||||||
|
return 0xffffffffffffffff;
|
||||||
|
}
|
||||||
|
|
||||||
/* TSC handling */
|
/* TSC handling */
|
||||||
uint64_t cpu_get_tsc(CPUX86State *env)
|
uint64_t cpu_get_tsc(CPUX86State *env)
|
||||||
{
|
{
|
||||||
|
@ -960,6 +970,7 @@ static void cpu_request_exit(void *opaque, int irq, int level)
|
||||||
|
|
||||||
static const MemoryRegionOps ioport80_io_ops = {
|
static const MemoryRegionOps ioport80_io_ops = {
|
||||||
.write = ioport80_write,
|
.write = ioport80_write,
|
||||||
|
.read = ioport80_read,
|
||||||
.endianness = DEVICE_NATIVE_ENDIAN,
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||||
.impl = {
|
.impl = {
|
||||||
.min_access_size = 1,
|
.min_access_size = 1,
|
||||||
|
@ -969,6 +980,7 @@ static const MemoryRegionOps ioport80_io_ops = {
|
||||||
|
|
||||||
static const MemoryRegionOps ioportF0_io_ops = {
|
static const MemoryRegionOps ioportF0_io_ops = {
|
||||||
.write = ioportF0_write,
|
.write = ioportF0_write,
|
||||||
|
.read = ioportF0_read,
|
||||||
.endianness = DEVICE_NATIVE_ENDIAN,
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||||
.impl = {
|
.impl = {
|
||||||
.min_access_size = 1,
|
.min_access_size = 1,
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "qemu/sockets.h"
|
#include "qemu/sockets.h"
|
||||||
#include "qga/channel.h"
|
#include "qga/channel.h"
|
||||||
|
|
|
@ -248,7 +248,7 @@ static void readline_hist_add(ReadLineState *rs, const char *cmdline)
|
||||||
if (idx == READLINE_MAX_CMDS) {
|
if (idx == READLINE_MAX_CMDS) {
|
||||||
/* Need to get one free slot */
|
/* Need to get one free slot */
|
||||||
free(rs->history[0]);
|
free(rs->history[0]);
|
||||||
memcpy(rs->history, &rs->history[1],
|
memmove(rs->history, &rs->history[1],
|
||||||
(READLINE_MAX_CMDS - 1) * sizeof(char *));
|
(READLINE_MAX_CMDS - 1) * sizeof(char *));
|
||||||
rs->history[READLINE_MAX_CMDS - 1] = NULL;
|
rs->history[READLINE_MAX_CMDS - 1] = NULL;
|
||||||
idx = READLINE_MAX_CMDS - 1;
|
idx = READLINE_MAX_CMDS - 1;
|
||||||
|
|
30
savevm.c
30
savevm.c
|
@ -23,15 +23,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config-host.h"
|
#include "config-host.h"
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "qemu-common.h"
|
#include "qemu-common.h"
|
||||||
#include "hw/hw.h"
|
#include "hw/hw.h"
|
||||||
#include "hw/qdev.h"
|
#include "hw/qdev.h"
|
||||||
|
@ -2093,13 +2084,8 @@ void do_savevm(Monitor *mon, const QDict *qdict)
|
||||||
QEMUFile *f;
|
QEMUFile *f;
|
||||||
int saved_vm_running;
|
int saved_vm_running;
|
||||||
uint64_t vm_state_size;
|
uint64_t vm_state_size;
|
||||||
#ifdef _WIN32
|
qemu_timeval tv;
|
||||||
struct _timeb tb;
|
|
||||||
struct tm *ptm;
|
|
||||||
#else
|
|
||||||
struct timeval tv;
|
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
#endif
|
|
||||||
const char *name = qdict_get_try_str(qdict, "name");
|
const char *name = qdict_get_try_str(qdict, "name");
|
||||||
|
|
||||||
/* Verify if there is a device that doesn't support snapshots and is writable */
|
/* Verify if there is a device that doesn't support snapshots and is writable */
|
||||||
|
@ -2129,15 +2115,9 @@ void do_savevm(Monitor *mon, const QDict *qdict)
|
||||||
memset(sn, 0, sizeof(*sn));
|
memset(sn, 0, sizeof(*sn));
|
||||||
|
|
||||||
/* fill auxiliary fields */
|
/* fill auxiliary fields */
|
||||||
#ifdef _WIN32
|
qemu_gettimeofday(&tv);
|
||||||
_ftime(&tb);
|
|
||||||
sn->date_sec = tb.time;
|
|
||||||
sn->date_nsec = tb.millitm * 1000000;
|
|
||||||
#else
|
|
||||||
gettimeofday(&tv, NULL);
|
|
||||||
sn->date_sec = tv.tv_sec;
|
sn->date_sec = tv.tv_sec;
|
||||||
sn->date_nsec = tv.tv_usec * 1000;
|
sn->date_nsec = tv.tv_usec * 1000;
|
||||||
#endif
|
|
||||||
sn->vm_clock_nsec = qemu_get_clock_ns(vm_clock);
|
sn->vm_clock_nsec = qemu_get_clock_ns(vm_clock);
|
||||||
|
|
||||||
if (name) {
|
if (name) {
|
||||||
|
@ -2149,15 +2129,9 @@ void do_savevm(Monitor *mon, const QDict *qdict)
|
||||||
pstrcpy(sn->name, sizeof(sn->name), name);
|
pstrcpy(sn->name, sizeof(sn->name), name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifdef _WIN32
|
|
||||||
time_t t = tb.time;
|
|
||||||
ptm = localtime(&t);
|
|
||||||
strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", ptm);
|
|
||||||
#else
|
|
||||||
/* cast below needed for OpenBSD where tv_sec is still 'long' */
|
/* cast below needed for OpenBSD where tv_sec is still 'long' */
|
||||||
localtime_r((const time_t *)&tv.tv_sec, &tm);
|
localtime_r((const time_t *)&tv.tv_sec, &tm);
|
||||||
strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", &tm);
|
strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", &tm);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete old snapshots of the same name */
|
/* Delete old snapshots of the same name */
|
||||||
|
|
9
vl.c
9
vl.c
|
@ -448,21 +448,18 @@ StatusInfo *qmp_query_status(Error **errp)
|
||||||
void qemu_get_timedate(struct tm *tm, int offset)
|
void qemu_get_timedate(struct tm *tm, int offset)
|
||||||
{
|
{
|
||||||
time_t ti;
|
time_t ti;
|
||||||
struct tm *ret;
|
|
||||||
|
|
||||||
time(&ti);
|
time(&ti);
|
||||||
ti += offset;
|
ti += offset;
|
||||||
if (rtc_date_offset == -1) {
|
if (rtc_date_offset == -1) {
|
||||||
if (rtc_utc)
|
if (rtc_utc)
|
||||||
ret = gmtime(&ti);
|
gmtime_r(&ti, tm);
|
||||||
else
|
else
|
||||||
ret = localtime(&ti);
|
localtime_r(&ti, tm);
|
||||||
} else {
|
} else {
|
||||||
ti -= rtc_date_offset;
|
ti -= rtc_date_offset;
|
||||||
ret = gmtime(&ti);
|
gmtime_r(&ti, tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(tm, ret, sizeof(struct tm));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int qemu_timedate_diff(struct tm *tm)
|
int qemu_timedate_diff(struct tm *tm)
|
||||||
|
|
Loading…
Reference in New Issue