From 1332407a0739b26d664428f5d3c1e7bc1161d7e2 Mon Sep 17 00:00:00 2001
From: Dan McDonald <danmcd@omniti.com>
Date: Fri, 8 May 2015 09:50:27 -0400
Subject: [PATCH] Revert "HVM-797 Vanquish Banquo's ghost"

This reverts commit 43aa6602f0d68ff7e032aad06645e34e9921d976.
---
 kvm.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 kvm.h |  1 +
 2 files changed, 58 insertions(+)

diff --git a/kvm.c b/kvm.c
index 6e136ac..1a55f49 100644
--- a/kvm.c
+++ b/kvm.c
@@ -2634,6 +2634,63 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int md, cred_t *cr, int *rv)
 		rval = kvm_vcpu_ioctl_nmi(ksp->kds_vcpu);
 		break;
 	}
+	case KVM_NET_QUEUE: {
+		struct vnode *vn;
+		file_t *fp;
+		struct stroptions *stropt;
+		mblk_t *mp;
+		queue_t *q;
+
+		fp = getf(arg);
+		if (fp == NULL) {
+			rval = EINVAL;
+			break;
+		}
+		ASSERT(fp->f_vnode);
+
+		if (fp->f_vnode->v_stream == NULL) {
+			releasef(arg);
+			rval = EINVAL;
+			break;
+		}
+
+		mp = allocb(sizeof (struct stroptions), BPRI_LO);
+		if (mp == NULL) {
+			releasef(arg);
+			rval = ENOMEM;
+		}
+
+		/*
+		 * This really just shouldn't need to exist, etc. and we
+		 * should really get the hiwat value more intelligently at least
+		 * a #define or a tunable god forbid. Oh well, as bmc said
+		 * earlier:
+		 * "I am in blood steeped in so far that I wade no more.
+		 * Returning were as tedious as go o'er.
+		 *
+		 * We'd love to just putmsg on RD(fp->f_vnode->v_stream->sd_wq)
+		 * however that would be the stream head. Instead, we need to
+		 * get the write version and then go to the next one and then
+		 * the opposite end. The doctor may hemorrhage before the
+		 * patient.
+		 *
+		 * Banquo's ghost is waiting to pop up
+		 */
+		mp->b_datap->db_type = M_SETOPTS;
+		stropt = (struct stroptions *)mp->b_rptr;
+		stropt->so_flags = SO_HIWAT;
+		stropt->so_hiwat = kvm_hiwat;
+		q = WR(fp->f_vnode->v_stream->sd_wrq);
+		q = RD(q->q_next);
+		putnext(q, mp);
+
+		releasef(arg);
+
+		rval = 0;
+		*rv = 0;
+		break;
+	}
+
 	default:
 		KVM_TRACE1(bad__ioctl, int, cmd);
 		rval = EINVAL;  /* x64, others may do other things... */
diff --git a/kvm.h b/kvm.h
index 7211b55..874c701 100644
--- a/kvm.h
+++ b/kvm.h
@@ -288,6 +288,7 @@ typedef struct kvm_guest_debug {
 #define	KVM_CREATE_VM		_IO(KVMIO,   0x01) /* returns a VM fd */
 #define	KVM_GET_MSR_INDEX_LIST	_IOWR(KVMIO, 0x02, struct kvm_msr_list)
 #define	KVM_CLONE		_IO(KVMIO,   0x20)
+#define	KVM_NET_QUEUE		_IO(KVMIO,   0x21)
 
 /*
  * Check if a kvm extension is available.  Argument is extension number,
-- 
2.3.0