kvm tools: Add '--no-dhcp' to disable kernel DHCP
PATCH v2 1/4 kvm tools: Add '--no-dhcp' to disable kernel DHCP
This new option disables the kernel DHCP which runs when starting a custom rootfs.
This is useful when we want to start a rootfs but are using a network other than the usermode IP proxy (a network which doesn't provide DHCP).
--- tools/kvm/builtin-run.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
tools/kvm/builtin-run.c +7 -2
@@ -91,6 +91,7 @@ static bool balloon;static bool using_rootfs;static bool custom_rootfs;static bool no_net; +static bool no_dhcp;extern bool ioport_debug;extern int active_console;extern int debug_iodelay;
@@ -432,6 +433,7 @@ static const struct option options[] = {OPT_CALLBACK_DEFAULT ('n' ,"network" ,NULL ,"network params" ,"Create a new guest NIC" , netdev_parser,NULL ), +OPT_BOOLEAN ('\0' ,"no-dhcp" , &no_dhcp,"Disable kernel DHCP in rootfs mode" ),OPT_GROUP ("BIOS options:" ), OPT_INTEGER('\0', "vidmode", &vidmode,
@@ -861,8 +863,11 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)if (using_rootfs) {strcat (real_cmdline," root=/dev/root rw rootflags=rw,trans=virtio,version=9p2000.L rootfstype=9p" ); -if (custom_rootfs) -strcat (real_cmdline," init=/virt/init ip=dhcp" ); +if (custom_rootfs) { +strcat (real_cmdline," init=/virt/init" ); +if (!no_dhcp) +strcat (real_cmdline," ip=dhcp" ); + } }else if (!strstr (real_cmdline,"root=" )) {strlcat (real_cmdline," root=/dev/vda rw " ,sizeof (real_cmdline)); }
Signature · 1 line
1.7.8.rc1
PATCH v2 2/4 kvm tools: Prepare support for VIRTIO_RING_F_EVENT_IDX
This patch is the base for enabling support for event index feature in the virtio spec. We do so by updating and evaluating the used/avail event idx in the virtio ring functions.
Actual usage of this flag is in the following patches.
The results are less notifications between the guest and host, and in result faster operation of the virt queues.
--- tools/kvm/include/kvm/virtio.h | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
tools/kvm/include/kvm/virtio.h +7 -0
@@ -38,6 +38,8 @@ static inline bool virt_queue__available(struct virt_queue *vq) {if (!vq->vring.avail)return 0 ; + +vring_avail_event (&vq->vring) = vq->last_avail_idx;return vq->vring.avail->idx != vq->last_avail_idx; }
@@ -51,6 +53,11 @@ static inline void *guest_pfn_to_host(struct kvm *kvm, u32 pfn)return guest_flat_to_host (kvm, (unsigned long )pfn <<VIRTIO_PCI_QUEUE_ADDR_SHIFT ); } +static inline int virtio_queue__should_signal (struct virt_queue *vq) +{ +return vring_used_event (&vq->vring) <= vq->vring.used->idx; +} +struct vring_used_elem *virt_queue__set_used_elem (struct virt_queue *queue,u32 head,u32 len);u16 virt_queue__get_iov (struct virt_queue *queue,struct iovec iov[],u16 *out,u16 *in,struct kvm *kvm);
Signature · 1 line
1.7.8.rc1
PATCH v2 3/4 kvm tools: Support event idx in virtio-net
In reply to Sasha LevinSupport event idx both when using vhost and when using simple TAP mode.
I did simple TCP stream performance test with vhost, and it showed another 9% increase over regular vhost mode.
--- tools/kvm/virtio/net.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-)
tools/kvm/virtio/net.c +8 -4
@@ -102,7 +102,9 @@ static void *virtio_net_rx_thread(void *p)virt_queue__set_used_elem (vq, head, len);/* We should interrupt guest right now, otherwise latency is huge. */ - ndev->vtrans.trans_ops->signal_vq (kvm, &ndev->vtrans,VIRTIO_NET_RX_QUEUE ); +if (virtio_queue__should_signal (&ndev->vqs[VIRTIO_NET_RX_QUEUE ])) + ndev->vtrans.trans_ops->signal_vq (kvm, &ndev->vtrans, +VIRTIO_NET_RX_QUEUE ); } }
@@ -140,7 +142,8 @@ static void *virtio_net_tx_thread(void *p)virt_queue__set_used_elem (vq, head, len); } - ndev->vtrans.trans_ops->signal_vq (kvm, &ndev->vtrans,VIRTIO_NET_TX_QUEUE ); +if (virtio_queue__should_signal (&ndev->vqs[VIRTIO_NET_TX_QUEUE ])) + ndev->vtrans.trans_ops->signal_vq (kvm, &ndev->vtrans,VIRTIO_NET_TX_QUEUE ); }pthread_exit (NULL );
@@ -314,7 +317,8 @@ static u32 get_host_features(struct kvm *kvm, void *dev) | 1UL << VIRTIO_NET_F_HOST_TSO6 |1UL <<VIRTIO_NET_F_GUEST_UFO |1UL <<VIRTIO_NET_F_GUEST_TSO4 - |1UL <<VIRTIO_NET_F_GUEST_TSO6 ; + |1UL <<VIRTIO_NET_F_GUEST_TSO6 + |1UL <<VIRTIO_RING_F_EVENT_IDX ; }static void set_guest_features (struct kvm *kvm,void *dev,u32 features)
@@ -453,7 +457,7 @@ static struct virtio_ops net_dev_virtio_ops = (struct virtio_ops) {static void virtio_net__vhost_init (struct kvm *kvm,struct net_dev *ndev) { -u64 features =0 ; +u64 features =1UL <<VIRTIO_RING_F_EVENT_IDX ;struct vhost_memory *mem;int r;
Signature · 1 line
1.7.8.rc1
PATCH v2 4/4 kvm tools: Add event idx support to virtio-blk
In reply to Sasha Levin--- tools/kvm/virtio/blk.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
tools/kvm/virtio/blk.c +5 -2
@@ -93,7 +93,8 @@ void virtio_blk_complete(void *param, long len)virt_queue__set_used_elem (req->vq, req->head, len);mutex_unlock (&bdev->mutex); - bdev->vtrans.trans_ops->signal_vq (req->kvm, &bdev->vtrans, queueid); +if (virtio_queue__should_signal (&bdev->vqs[queueid])) + bdev->vtrans.trans_ops->signal_vq (req->kvm, &bdev->vtrans, queueid);virtio_blk_req_push (req->bdev, req); }
@@ -170,7 +171,9 @@ static u8 get_config(struct kvm *kvm, void *dev, u32 offset)static u32 get_host_features (struct kvm *kvm,void *dev) { -return 1UL <<VIRTIO_BLK_F_SEG_MAX |1UL <<VIRTIO_BLK_F_FLUSH ; +return 1UL <<VIRTIO_BLK_F_SEG_MAX + |1UL <<VIRTIO_BLK_F_FLUSH + |1UL <<VIRTIO_RING_F_EVENT_IDX ; }static void set_guest_features (struct kvm *kvm,void *dev,u32 features)
Signature · 1 line
1.7.8.rc1