~ubuntu-branches/ubuntu/trusty/qemu/trusty

« back to all changes in this revision

Viewing changes to hw/i386/kvm/i8254.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2013-10-22 22:47:07 UTC
  • mfrom: (1.8.3) (10.1.42 sid)
  • Revision ID: package-import@ubuntu.com-20131022224707-1lya34fw3k3f24tv
Tags: 1.6.0+dfsg-2ubuntu1
* Merge 1.6.0~rc0+dfsg-2exp from debian experimental.  Remaining changes:
  - debian/control
    * update maintainer
    * remove libiscsi, usb-redir, vde, vnc-jpeg, and libssh2-1-dev
      from build-deps
    * enable rbd
    * add qemu-system and qemu-common B/R to qemu-keymaps
    * add D:udev, R:qemu, R:qemu-common and B:qemu-common to
      qemu-system-common
    * qemu-system-arm, qemu-system-ppc, qemu-system-sparc:
      - add qemu-kvm to Provides
      - add qemu-common, qemu-kvm, kvm to B/R
      - remove openbios-sparc from qemu-system-sparc D
      - drop openbios-ppc and openhackware Depends to Suggests (for now)
    * qemu-system-x86:
      - add qemu-common to Breaks/Replaces.
      - add cpu-checker to Recommends.
    * qemu-user: add B/R:qemu-kvm
    * qemu-kvm:
      - add armhf armel powerpc sparc to Architecture
      - C/R/P: qemu-kvm-spice
    * add qemu-common package
    * drop qemu-slof which is not packaged in ubuntu
  - add qemu-system-common.links for tap ifup/down scripts and OVMF link.
  - qemu-system-x86.links:
    * remove pxe rom links which are in kvm-ipxe
    * add symlink for kvm.1 manpage
  - debian/rules
    * add kvm-spice symlink to qemu-kvm
    * call dh_installmodules for qemu-system-x86
    * update dh_installinit to install upstart script
    * run dh_installman (Closes: #709241) (cherrypicked from 1.5.0+dfsg-2)
  - Add qemu-utils.links for kvm-* symlinks.
  - Add qemu-system-x86.qemu-kvm.upstart and .default
  - Add qemu-system-x86.modprobe to set nesting=1
  - Add qemu-system-common.preinst to add kvm group
  - qemu-system-common.postinst: remove bad group acl if there, then have
    udev relabel /dev/kvm.
  - New linaro patches from qemu-linaro rebasing branch
  - Dropped patches:
    * xen-simplify-xen_enabled.patch
    * sparc-linux-user-fix-missing-symbols-in-.rel-.rela.plt-sections.patch
    * main_loop-do-not-set-nonblocking-if-xen_enabled.patch
    * xen_machine_pv-do-not-create-a-dummy-CPU-in-machine-.patch
    * virtio-rng-fix-crash
  - Kept patches:
    * expose_vms_qemu64cpu.patch - updated
    * linaro arm patches from qemu-linaro rebasing branch
  - New patches:
    * fix-pci-add: change CONFIG variable in ifdef to make sure that
      pci_add is defined.
* Add linaro patches
* Add experimental mach-virt patches for arm virtualization.
* qemu-system-common.install: add debian/tmp/usr/lib to install the
  qemu-bridge-helper

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
#define CALIBRATION_ROUNDS   3
34
34
 
 
35
#define KVM_PIT(obj) OBJECT_CHECK(KVMPITState, (obj), TYPE_KVM_I8254)
 
36
#define KVM_PIT_CLASS(class) \
 
37
    OBJECT_CLASS_CHECK(KVMPITClass, (class), TYPE_KVM_I8254)
 
38
#define KVM_PIT_GET_CLASS(obj) \
 
39
    OBJECT_GET_CLASS(KVMPITClass, (obj), TYPE_KVM_I8254)
 
40
 
35
41
typedef struct KVMPITState {
36
 
    PITCommonState pit;
 
42
    PITCommonState parent_obj;
 
43
 
37
44
    LostTickPolicy lost_tick_policy;
38
45
    bool vm_stopped;
39
46
    int64_t kernel_clock_offset;
40
47
} KVMPITState;
41
48
 
 
49
typedef struct KVMPITClass {
 
50
    PITCommonClass parent_class;
 
51
 
 
52
    DeviceRealize parent_realize;
 
53
} KVMPITClass;
 
54
 
42
55
static int64_t abs64(int64_t v)
43
56
{
44
57
    return v < 0 ? -v : v;
70
83
 
71
84
static void kvm_pit_get(PITCommonState *pit)
72
85
{
73
 
    KVMPITState *s = DO_UPCAST(KVMPITState, pit, pit);
 
86
    KVMPITState *s = KVM_PIT(pit);
74
87
    struct kvm_pit_state2 kpit;
75
88
    struct kvm_pit_channel_state *kchan;
76
89
    struct PITChannelState *sc;
124
137
 
125
138
static void kvm_pit_put(PITCommonState *pit)
126
139
{
127
 
    KVMPITState *s = DO_UPCAST(KVMPITState, pit, pit);
 
140
    KVMPITState *s = KVM_PIT(pit);
128
141
    struct kvm_pit_state2 kpit;
129
142
    struct kvm_pit_channel_state *kchan;
130
143
    struct PITChannelState *sc;
200
213
 
201
214
static void kvm_pit_reset(DeviceState *dev)
202
215
{
203
 
    PITCommonState *s = DO_UPCAST(PITCommonState, dev.qdev, dev);
 
216
    PITCommonState *s = PIT_COMMON(dev);
204
217
 
205
218
    pit_reset_common(s);
206
219
 
229
242
        s->vm_stopped = false;
230
243
    } else {
231
244
        kvm_pit_update_clock_offset(s);
232
 
        kvm_pit_get(&s->pit);
 
245
        kvm_pit_get(PIT_COMMON(s));
233
246
        s->vm_stopped = true;
234
247
    }
235
248
}
236
249
 
237
 
static int kvm_pit_initfn(PITCommonState *pit)
 
250
static void kvm_pit_realizefn(DeviceState *dev, Error **errp)
238
251
{
239
 
    KVMPITState *s = DO_UPCAST(KVMPITState, pit, pit);
 
252
    PITCommonState *pit = PIT_COMMON(dev);
 
253
    KVMPITClass *kpc = KVM_PIT_GET_CLASS(dev);
 
254
    KVMPITState *s = KVM_PIT(pit);
240
255
    struct kvm_pit_config config = {
241
256
        .flags = 0,
242
257
    };
248
263
        ret = kvm_vm_ioctl(kvm_state, KVM_CREATE_PIT);
249
264
    }
250
265
    if (ret < 0) {
251
 
        fprintf(stderr, "Create kernel PIC irqchip failed: %s\n",
252
 
                strerror(ret));
253
 
        return ret;
 
266
        error_setg(errp, "Create kernel PIC irqchip failed: %s",
 
267
                   strerror(ret));
 
268
        return;
254
269
    }
255
270
    switch (s->lost_tick_policy) {
256
271
    case LOST_TICK_DELAY:
261
276
 
262
277
            ret = kvm_vm_ioctl(kvm_state, KVM_REINJECT_CONTROL, &control);
263
278
            if (ret < 0) {
264
 
                fprintf(stderr,
265
 
                        "Can't disable in-kernel PIT reinjection: %s\n",
266
 
                        strerror(ret));
267
 
                return ret;
 
279
                error_setg(errp,
 
280
                           "Can't disable in-kernel PIT reinjection: %s",
 
281
                           strerror(ret));
 
282
                return;
268
283
            }
269
284
        }
270
285
        break;
271
286
    default:
272
 
        return -EINVAL;
 
287
        error_setg(errp, "Lost tick policy not supported.");
 
288
        return;
273
289
    }
274
290
 
275
 
    memory_region_init_reservation(&pit->ioports, "kvm-pit", 4);
 
291
    memory_region_init_reservation(&pit->ioports, NULL, "kvm-pit", 4);
276
292
 
277
 
    qdev_init_gpio_in(&pit->dev.qdev, kvm_pit_irq_control, 1);
 
293
    qdev_init_gpio_in(dev, kvm_pit_irq_control, 1);
278
294
 
279
295
    qemu_add_vm_change_state_handler(kvm_pit_vm_state_change, s);
280
296
 
281
 
    return 0;
 
297
    kpc->parent_realize(dev, errp);
282
298
}
283
299
 
284
300
static Property kvm_pit_properties[] = {
285
 
    DEFINE_PROP_HEX32("iobase", KVMPITState, pit.iobase,  -1),
 
301
    DEFINE_PROP_HEX32("iobase", PITCommonState, iobase,  -1),
286
302
    DEFINE_PROP_LOSTTICKPOLICY("lost_tick_policy", KVMPITState,
287
303
                               lost_tick_policy, LOST_TICK_DELAY),
288
304
    DEFINE_PROP_END_OF_LIST(),
290
306
 
291
307
static void kvm_pit_class_init(ObjectClass *klass, void *data)
292
308
{
 
309
    KVMPITClass *kpc = KVM_PIT_CLASS(klass);
293
310
    PITCommonClass *k = PIT_COMMON_CLASS(klass);
294
311
    DeviceClass *dc = DEVICE_CLASS(klass);
295
312
 
296
 
    k->init = kvm_pit_initfn;
 
313
    kpc->parent_realize = dc->realize;
 
314
    dc->realize = kvm_pit_realizefn;
297
315
    k->set_channel_gate = kvm_pit_set_gate;
298
316
    k->get_channel_info = kvm_pit_get_channel_info;
299
317
    k->pre_save = kvm_pit_get;
303
321
}
304
322
 
305
323
static const TypeInfo kvm_pit_info = {
306
 
    .name          = "kvm-pit",
 
324
    .name          = TYPE_KVM_I8254,
307
325
    .parent        = TYPE_PIT_COMMON,
308
326
    .instance_size = sizeof(KVMPITState),
309
327
    .class_init = kvm_pit_class_init,
 
328
    .class_size = sizeof(KVMPITClass),
310
329
};
311
330
 
312
331
static void kvm_pit_register(void)