From: Luiz Capitulino <lcapitulino@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 08/19] Convert RTC to use enumerations for configuration parameters
Date: Wed, 9 Jun 2010 16:54:36 -0300 [thread overview]
Message-ID: <20100609165436.2982292c@redhat.com> (raw)
In-Reply-To: <1275921752-29420-9-git-send-email-berrange@redhat.com>
On Mon, 7 Jun 2010 15:42:21 +0100
"Daniel P. Berrange" <berrange@redhat.com> wrote:
> Convert the rtc clock and driftfix parameters to use enums for
> configuration. This ensures strict validation at time of config
> parsing.
>
> Also fixes a bug in qemu-config.c where 'driftfix' was never
> enabled because this is a target independant compliation unit,
> thus cannot include config-target.h and thus never has the
> TARGET_I386 symbol defined.
>
> Ideally the 'base' parameter would be an enum too, but this
> value is overloaded to also accept a pretty-printed start
> date.
>
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
> hw/mc146818rtc.c | 8 ++++----
> qemu-config.c | 27 +++++++++++++++++++++++----
> sysemu.h | 20 +++++++++++++++++++-
> vl.c | 34 ++++++++++------------------------
> 4 files changed, 56 insertions(+), 33 deletions(-)
>
> diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
> index c3e6a70..cbb072c 100644
> --- a/hw/mc146818rtc.c
> +++ b/hw/mc146818rtc.c
> @@ -202,7 +202,7 @@ static void rtc_periodic_timer(void *opaque)
> if (s->cmos_data[RTC_REG_B] & REG_B_PIE) {
> s->cmos_data[RTC_REG_C] |= 0xc0;
> #ifdef TARGET_I386
> - if(rtc_td_hack) {
> + if(rtc_driftfix == QEMU_RTC_DRIFTFIX_SLEW) {
> if (s->irq_reinject_on_ack_count >= RTC_REINJECT_ON_ACK_COUNT)
> s->irq_reinject_on_ack_count = 0;
> apic_reset_irq_delivered();
> @@ -552,7 +552,7 @@ static int rtc_post_load(void *opaque, int version_id)
> RTCState *s = opaque;
>
> if (version_id >= 2) {
> - if (rtc_td_hack) {
> + if (rtc_driftfix == QEMU_RTC_DRIFTFIX_SLEW) {
> rtc_coalesced_timer_update(s);
> }
> }
> @@ -597,7 +597,7 @@ static void rtc_reset(void *opaque)
> qemu_irq_lower(s->irq);
>
> #ifdef TARGET_I386
> - if (rtc_td_hack)
> + if (rtc_driftfix == QEMU_RTC_DRIFTFIX_SLEW)
> s->irq_coalesced = 0;
> #endif
> }
> @@ -619,7 +619,7 @@ static int rtc_initfn(ISADevice *dev)
>
> s->periodic_timer = qemu_new_timer(rtc_clock, rtc_periodic_timer, s);
> #ifdef TARGET_I386
> - if (rtc_td_hack)
> + if (rtc_driftfix == QEMU_RTC_DRIFTFIX_SLEW)
> s->coalesced_timer =
> qemu_new_timer(rtc_clock, rtc_coalesced_timer, s);
> #endif
> diff --git a/qemu-config.c b/qemu-config.c
> index f656e6b..75cddc1 100644
> --- a/qemu-config.c
> +++ b/qemu-config.c
> @@ -288,6 +288,11 @@ QemuOptsList qemu_net_opts = {
> },
> };
>
> +QEMU_ENUM_IMPL(qemu_rtc_clock, QEMU_RTC_CLOCK_LAST,
> + "host", "guest");
> +QEMU_ENUM_IMPL(qemu_rtc_driftfix, QEMU_RTC_DRIFTFIX_LAST,
> + "none", "slew");
> +
> QemuOptsList qemu_rtc_opts = {
> .name = "rtc",
> .head = QTAILQ_HEAD_INITIALIZER(qemu_rtc_opts.head),
> @@ -297,12 +302,26 @@ QemuOptsList qemu_rtc_opts = {
> .type = QEMU_OPT_STRING,
> },{
> .name = "clock",
> - .type = QEMU_OPT_STRING,
> -#ifdef TARGET_I386
> + .type = QEMU_OPT_ENUM,
> + .validate = {
> + .optEnum = {
> + .to_string = qemu_rtc_clock_to_string,
> + .to_string_list = qemu_rtc_clock_to_string_list,
> + .from_string = qemu_rtc_clock_from_string,
> + .last = QEMU_RTC_CLOCK_LAST,
> + },
> + },
> },{
> .name = "driftfix",
> - .type = QEMU_OPT_STRING,
> -#endif
> + .type = QEMU_OPT_ENUM,
> + .validate = {
> + .optEnum = {
> + .to_string = qemu_rtc_driftfix_to_string,
> + .to_string_list = qemu_rtc_driftfix_to_string_list,
> + .from_string = qemu_rtc_driftfix_from_string,
> + .last = QEMU_RTC_DRIFTFIX_LAST,
> + },
> + },
> },
> { /* end if list */ }
> },
> diff --git a/sysemu.h b/sysemu.h
> index f0c5eb8..4d39566 100644
> --- a/sysemu.h
> +++ b/sysemu.h
> @@ -120,7 +120,6 @@ extern uint8_t irq0override;
> extern DisplayType display_type;
> extern const char *keyboard_layout;
> extern int win2k_install_hack;
> -extern int rtc_td_hack;
> extern int alt_grab;
> extern int ctrl_grab;
> extern int usb_enabled;
> @@ -133,7 +132,26 @@ extern int no_shutdown;
> extern int semihosting_enabled;
> extern int old_param;
> extern int boot_menu;
> +
> extern QEMUClock *rtc_clock;
> +extern int rtc_driftfix;
> +
> +enum {
> + QEMU_RTC_CLOCK_HOST,
> + QEMU_RTC_CLOCK_GUEST,
> +
> + QEMU_RTC_CLOCK_LAST
> +};
> +QEMU_ENUM_DECL(qemu_rtc_clock);
> +
> +enum {
> + QEMU_RTC_DRIFTFIX_NONE,
> + QEMU_RTC_DRIFTFIX_SLEW,
> +
> + QEMU_RTC_DRIFTFIX_LAST
> +};
> +QEMU_ENUM_DECL(qemu_rtc_driftfix);
> +
>
> #define MAX_NODES 64
> extern int nb_numa_nodes;
> diff --git a/vl.c b/vl.c
> index 16491c4..0b38d62 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -201,7 +201,7 @@ CharDriverState *serial_hds[MAX_SERIAL_PORTS];
> CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
> CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES];
> int win2k_install_hack = 0;
> -int rtc_td_hack = 0;
> +int rtc_driftfix = QEMU_RTC_DRIFTFIX_NONE;
> int usb_enabled = 0;
> int singlestep = 0;
> int smp_cpus = 1;
> @@ -418,6 +418,9 @@ static void configure_rtc_date_offset(const char *startdate, int legacy)
> static void configure_rtc(QemuOpts *opts)
> {
> const char *value;
> + QEMUClock *clocks[] = { host_clock, vm_clock };
> + verify_true(ARRAY_SIZE(clocks) == QEMU_RTC_CLOCK_LAST);
This and the other verify_true() usage are generating the following
build error for me when debug is enabled:
cc1: warnings being treated as errors
/home/lcapitulino/src/qmp-unstable/vl.c: In function ‘configure_rtc’:
/home/lcapitulino/src/qmp-unstable/vl.c:422: error: statement with no effect
/home/lcapitulino/src/qmp-unstable/vl.c: In function ‘drive_init’:
/home/lcapitulino/src/qmp-unstable/vl.c:847: error: statement with no effect
make[1]: *** [vl.o] Error 1
make: *** [subdir-libhw64] Error 2
> + int clock;
>
> value = qemu_opt_get(opts, "base");
> if (value) {
> @@ -429,28 +432,11 @@ static void configure_rtc(QemuOpts *opts)
> configure_rtc_date_offset(value, 0);
> }
> }
> - value = qemu_opt_get(opts, "clock");
> - if (value) {
> - if (!strcmp(value, "host")) {
> - rtc_clock = host_clock;
> - } else if (!strcmp(value, "vm")) {
> - rtc_clock = vm_clock;
> - } else {
> - fprintf(stderr, "qemu: invalid option value '%s'\n", value);
> - exit(1);
> - }
> - }
> - value = qemu_opt_get(opts, "driftfix");
> - if (value) {
> - if (!strcmp(value, "slew")) {
> - rtc_td_hack = 1;
> - } else if (!strcmp(value, "none")) {
> - rtc_td_hack = 0;
> - } else {
> - fprintf(stderr, "qemu: invalid option value '%s'\n", value);
> - exit(1);
> - }
> - }
> +
> + clock = qemu_opt_get_enum(opts, "clock", QEMU_RTC_CLOCK_HOST);
> + rtc_clock = clocks[clock];
> +
> + rtc_driftfix = qemu_opt_get_enum(opts, "driftfix", QEMU_RTC_DRIFTFIX_NONE);
> }
>
> /***********************************************************/
> @@ -3149,7 +3135,7 @@ int main(int argc, char **argv, char **envp)
> win2k_install_hack = 1;
> break;
> case QEMU_OPTION_rtc_td_hack:
> - rtc_td_hack = 1;
> + rtc_driftfix = QEMU_RTC_DRIFTFIX_SLEW;
> break;
> case QEMU_OPTION_acpitable:
> do_acpitable_option(optarg);
next prev parent reply other threads:[~2010-06-09 19:54 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-07 14:42 [Qemu-devel] [PATCH 00/19] RFC: Reporting QEMU binary capabilities Daniel P. Berrange
2010-06-07 14:42 ` [Qemu-devel] [PATCH 01/19] Add support for JSON pretty printing Daniel P. Berrange
2010-06-09 19:51 ` Luiz Capitulino
2010-06-07 14:42 ` [Qemu-devel] [PATCH 02/19] Add support for compile time assertions Daniel P. Berrange
2010-06-07 15:35 ` [Qemu-devel] " Paolo Bonzini
2010-06-07 14:42 ` [Qemu-devel] [PATCH 03/19] Add enum handlers for easy & efficient string <-> int conversion Daniel P. Berrange
2010-06-09 19:52 ` Luiz Capitulino
2010-06-26 6:52 ` Markus Armbruster
2010-06-07 14:42 ` [Qemu-devel] [PATCH 04/19] Add support for a option parameter as an enum Daniel P. Berrange
2010-06-26 6:59 ` Markus Armbruster
2010-06-07 14:42 ` [Qemu-devel] [PATCH 05/19] Ensure that QEMU exits if drive_add parsing fails Daniel P. Berrange
2010-06-26 7:04 ` Markus Armbruster
2010-06-07 14:42 ` [Qemu-devel] [PATCH 06/19] Convert drive options to use enumeration data type Daniel P. Berrange
2010-06-09 19:52 ` Luiz Capitulino
2010-06-26 7:07 ` Markus Armbruster
2010-06-07 14:42 ` [Qemu-devel] [PATCH 07/19] Convert netdev client types to use an enumeration Daniel P. Berrange
2010-06-07 15:09 ` Anthony Liguori
2010-06-07 15:13 ` Daniel P. Berrange
2010-06-07 14:42 ` [Qemu-devel] [PATCH 08/19] Convert RTC to use enumerations for configuration parameters Daniel P. Berrange
2010-06-09 19:54 ` Luiz Capitulino [this message]
2010-06-07 14:42 ` [Qemu-devel] [PATCH 09/19] Change 'query-version' to output broken down version string Daniel P. Berrange
2010-06-07 15:11 ` Anthony Liguori
2010-06-09 20:04 ` Luiz Capitulino
2010-06-07 14:42 ` [Qemu-devel] [PATCH 10/19] Add a query-machines command to QMP Daniel P. Berrange
2010-06-07 15:13 ` Anthony Liguori
2010-06-07 16:44 ` Daniel P. Berrange
2010-06-07 17:07 ` Anthony Liguori
2010-06-07 17:14 ` Daniel P. Berrange
2010-06-09 20:06 ` Luiz Capitulino
2010-06-07 14:42 ` [Qemu-devel] [PATCH 11/19] Add a query-devices " Daniel P. Berrange
2010-06-07 15:14 ` Anthony Liguori
2010-06-07 16:03 ` Daniel P. Berrange
2010-06-26 7:12 ` Markus Armbruster
2010-06-07 14:42 ` [Qemu-devel] [PATCH 12/19] Add a query-cputypes " Daniel P. Berrange
2010-06-26 7:18 ` Markus Armbruster
2010-06-07 14:42 ` [Qemu-devel] [PATCH 13/19] Add a query-target " Daniel P. Berrange
2010-06-07 15:43 ` [Qemu-devel] " Paolo Bonzini
2010-06-07 14:42 ` [Qemu-devel] [PATCH 14/19] Add a query-argv " Daniel P. Berrange
2010-06-07 15:01 ` Anthony Liguori
2010-06-10 15:34 ` [Qemu-devel] " Paolo Bonzini
2010-06-26 7:30 ` [Qemu-devel] " Markus Armbruster
2010-06-07 14:42 ` [Qemu-devel] [PATCH 15/19] Expand query-argv to include help string Daniel P. Berrange
2010-06-07 14:42 ` [Qemu-devel] [PATCH 16/19] Add a query-netdev command to QMP Daniel P. Berrange
2010-06-07 15:15 ` Anthony Liguori
2010-06-26 7:32 ` Markus Armbruster
2010-06-07 19:13 ` Miguel Di Ciurcio Filho
2010-06-08 8:38 ` Daniel P. Berrange
2010-06-07 14:42 ` [Qemu-devel] [PATCH 17/19] Add a query-config " Daniel P. Berrange
2010-06-26 7:34 ` Markus Armbruster
2010-06-07 14:42 ` [Qemu-devel] [PATCH 18/19] Add option to turn on JSON pretty printing in monitor Daniel P. Berrange
2010-06-07 14:42 ` [Qemu-devel] [PATCH 19/19] Add a -capabilities argument to allow easy query for static QEMU info Daniel P. Berrange
2010-06-07 16:04 ` [Qemu-devel] " Paolo Bonzini
2010-06-07 16:09 ` Daniel P. Berrange
2010-06-07 16:04 ` [Qemu-devel] " Anthony Liguori
2010-06-07 14:58 ` [Qemu-devel] [PATCH 00/19] RFC: Reporting QEMU binary capabilities Anthony Liguori
2010-06-07 15:10 ` Daniel P. Berrange
2010-06-07 15:18 ` Anthony Liguori
2010-06-07 16:02 ` [Qemu-devel] " Paolo Bonzini
2010-06-07 16:03 ` Anthony Liguori
2010-06-07 16:07 ` [Qemu-devel] " Anthony Liguori
2010-06-09 20:25 ` Luiz Capitulino
2010-06-26 6:45 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100609165436.2982292c@redhat.com \
--to=lcapitulino@redhat.com \
--cc=berrange@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).