From patchwork Thu Feb 3 13:44:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Obergfell X-Patchwork-Id: 529321 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p13DiD1Q030194 for ; Thu, 3 Feb 2011 13:44:13 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756401Ab1BCNoK (ORCPT ); Thu, 3 Feb 2011 08:44:10 -0500 Received: from mx3-phx2.redhat.com ([209.132.183.24]:52278 "EHLO mx3-phx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756395Ab1BCNoJ (ORCPT ); Thu, 3 Feb 2011 08:44:09 -0500 Received: from mail03.corp.redhat.com (zmail07.collab.prod.int.phx2.redhat.com [10.5.5.47]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p13Di9CQ030990; Thu, 3 Feb 2011 08:44:09 -0500 Date: Thu, 3 Feb 2011 08:44:09 -0500 (EST) From: Ulrich Obergfell To: kvm Cc: Glauber Costa , Avi Kivity Message-ID: <1367087615.226278.1296740649721.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com> In-Reply-To: <409993620.225098.1296734606159.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com> Subject: [RFC: 1/2] patch for QEMU HPET periodic timer emulation to alleviate time drift (code part 1) MIME-Version: 1.0 X-Originating-IP: [10.5.5.72] X-Mailer: Zimbra 6.0.9_GA_2686 (ZimbraWebClient - FF3.0 (Linux)/6.0.9_GA_2686) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 03 Feb 2011 13:44:13 +0000 (UTC) diff -up ./qemu-config.c.orig1 ./qemu-config.c --- ./qemu-config.c.orig1 2011-01-21 23:34:47.000000000 +0100 +++ ./qemu-config.c 2011-02-01 19:38:26.665250920 +0100 @@ -255,6 +255,21 @@ static QemuOptsList qemu_rtc_opts = { }, }; +static QemuOptsList qemu_hpet_opts = { + .name = "hpet", + .head = QTAILQ_HEAD_INITIALIZER(qemu_hpet_opts.head), + .desc = { + { + .name = "device", + .type = QEMU_OPT_STRING, + },{ + .name = "driftfix", + .type = QEMU_OPT_STRING, + }, + { /* end of list */ } + }, +}; + static QemuOptsList qemu_global_opts = { .name = "global", .head = QTAILQ_HEAD_INITIALIZER(qemu_global_opts.head), @@ -456,6 +471,7 @@ static QemuOptsList *vm_config_groups[32 &qemu_netdev_opts, &qemu_net_opts, &qemu_rtc_opts, + &qemu_hpet_opts, &qemu_global_opts, &qemu_mon_opts, &qemu_cpudef_opts, diff -up ./qemu-options.hx.orig1 ./qemu-options.hx --- ./qemu-options.hx.orig1 2011-01-21 23:34:47.000000000 +0100 +++ ./qemu-options.hx 2011-02-01 16:01:26.063249119 +0100 @@ -972,6 +972,11 @@ STEXI Disable HPET support. ETEXI +DEF("hpet", HAS_ARG, QEMU_OPTION_hpet, \ + "-hpet [device=none|present][,driftfix=none|slew]\n" \ + " disable or enable HPET, disable or enable drift fix for periodic timers (x86 only)\n", + QEMU_ARCH_ALL) + DEF("balloon", HAS_ARG, QEMU_OPTION_balloon, "-balloon none disable balloon device\n" "-balloon virtio[,addr=str]\n" diff -up ./vl.c.orig1 ./vl.c --- ./vl.c.orig1 2011-01-21 23:34:47.000000000 +0100 +++ ./vl.c 2011-02-01 19:39:22.163249205 +0100 @@ -203,6 +203,7 @@ CharDriverState *parallel_hds[MAX_PARALL CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES]; int win2k_install_hack = 0; int rtc_td_hack = 0; +int hpet_driftfix = 0; int usb_enabled = 0; int singlestep = 0; int smp_cpus = 1; @@ -431,6 +432,39 @@ static void configure_rtc(QemuOpts *opts } } +static void configure_hpet(QemuOpts *opts) +{ + const char *value, *opt; + + opt = "device"; + value = qemu_opt_get(opts, opt); + if (value) { + if (!strcmp(value, "present")) { + no_hpet = 0; + } else if (!strcmp(value, "none")) { + no_hpet = 1; + } else { + goto error_exit; + } + } + opt = "driftfix"; + value = qemu_opt_get(opts, opt); + if (value) { + if (!strcmp(value, "slew")) { + hpet_driftfix = 1; + } else if (!strcmp(value, "none")) { + hpet_driftfix = 0; + } else { + goto error_exit; + } + } + return; + +error_exit: + fprintf(stderr, "qemu: -hpet option '%s': value missing or invalid\n", opt); + exit(1); +} + /***********************************************************/ /* Bluetooth support */ static int nb_hcis; @@ -2608,6 +2642,13 @@ int main(int argc, char **argv, char **e case QEMU_OPTION_no_hpet: no_hpet = 1; break; + case QEMU_OPTION_hpet: + opts = qemu_opts_parse(qemu_find_opts("hpet"), optarg, 0); + if (!opts) { + exit(1); + } + configure_hpet(opts); + break; case QEMU_OPTION_balloon: if (balloon_parse(optarg) < 0) { fprintf(stderr, "Unknown -balloon argument %s\n", optarg);