Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

HVM-503 SmartOS kvm driver should create /dev entry for /dev/kvm

  • Loading branch information...
commit 1f4247e8b7935afd4b429531c9c26658ac50ec06 1 parent 8abc3de
@rmustacc rmustacc authored
Showing with 69 additions and 4 deletions.
  1. +1 −0  .gitignore
  2. +9 −4 Makefile
  3. +59 −0 kvm_link.c
View
1  .gitignore
@@ -55,3 +55,4 @@ pc-bios/optionrom/multiboot.raw
cscope.*
\#*
kvm.so
+JOY_kvm_link.so
View
13 Makefile
@@ -18,7 +18,7 @@ HDRCHK=tools/hdrchk
HDRCHK_USRFLAG="gcc"
HDRCHK_SYSFLAG="gcc -D_KERNEL"
-all: kvm kvm.so
+all: kvm kvm.so JOY_kvm_link.so
HEADERS= \
kvm.h \
@@ -68,7 +68,7 @@ HDRCHK_SYSHDRS= \
kvm_x86host.h \
kvm_x86impl.h
-kvm: kvm.c kvm_x86.c kvm_emulate.c kvm.h kvm_x86host.h msr.h kvm_bitops.h kvm_irq.c kvm_i8254.c kvm_lapic.c kvm_mmu.c kvm_iodev.c kvm_ioapic.c kvm_vmx.c kvm_i8259.c kvm_coalesced_mmio.c kvm_irq_comm.c kvm_cache_regs.c kvm_bitops.c $(HEADERS)
+kvm: kvm.c kvm_x86.c kvm_emulate.c kvm.h kvm_x86host.h msr.h kvm_bitops.h kvm_irq.c kvm_i8254.c kvm_lapic.c kvm_mmu.c kvm_iodev.c kvm_ioapic.c kvm_vmx.c kvm_i8259.c kvm_coalesced_mmio.c kvm_irq_comm.c kvm_cache_regs.c kvm_bitops.c $(HEADERS)
$(CC) $(CFLAGS) $(INCLUDEDIR) kvm.c
$(CC) $(CFLAGS) $(INCLUDEDIR) kvm_x86.c
$(CC) $(CFLAGS) $(INCLUDEDIR) kvm_emulate.c
@@ -106,6 +106,10 @@ kvm.so: kvm_mdb.c
gcc -m64 -shared \
-fPIC $(CFLAGS) $(INCLUDEDIR) -I/usr/include -o $@ kvm_mdb.c
+JOY_kvm_link.so: kvm_link.c
+ /opt/SUNWspro/bin/cc -O -xspace -Xa -xildoff -errtags=yes -errwarn=%all -erroff=E_EMPTY_TRANSLATION_UNIT -erroff=E_STATEMENT_NOT_REACHED -xc99=%none -W0,-xglobalstatic -v -K pic -DTEXT_DOMAIN=\"SUNW_OST_OSCMD\" -D_TS_ERRNO -I/root/src/illumos-live/proto/usr/include -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -I/root/src/illumos-live/projects/illumos/usr/src/cmd/devfsadm/ -I/root/src/illumos-live/projects/illumos/usr/src/cmd/devfsadm/../../uts/common -I/root/src/illumos-live/projects/illumos/usr/src/cmd/devfsadm/../modload -c -o kvm_link.o kvm_link.c
+ /opt/SUNWspro/bin/cc -o JOY_kvm_link.so -G -ztext -zdefs -Bdirect -M/root/src/illumos-live/projects/illumos/usr/src/cmd/devfsadm/mapfile-vers -M/root/src/illumos-live/projects/illumos/usr/src/common/mapfiles/common/map.pagealign -M/root/src/illumos-live/projects/illumos/usr/src/common/mapfiles/common/map.noexdata -h JOY_kvm_link.so kvm_link.o -L/root/src/illumos-live/proto/lib -L/root/src/illumos-live/proto/usr/lib -ldevinfo -lc
+
install: kvm
@echo "==> Installing kvm module (to $(DESTDIR)/)"
@mkdir -p $(DESTDIR)/usr/kernel/drv/amd64
@@ -113,15 +117,16 @@ install: kvm
@cp kvm.conf $(DESTDIR)/usr/kernel/drv
@mkdir -p $(DESTDIR)/usr/lib/mdb/kvm/amd64
@cp kvm.so $(DESTDIR)/usr/lib/mdb/kvm/amd64
+ @cp JOY_kvm_link.so $(DESTDIR)/usr/lib/devfsadm/linkmod
check:
- @$(CSTYLE) kvm.c kvm_mdb.c kvm_emulate.c kvm_x86.c kvm_irq.c kvm_lapic.c kvm_i8254.c kvm_mmu.c kvm_iodev.c kvm_ioapic.c kvm_vmx.c kvm_i8259.c kvm_coalesced_mmio.c kvm_irq_comm.c kvm_cache_regs.c kvm_bitops.c $(HEADERS)
+ @$(CSTYLE) kvm.c kvm_mdb.c kvm_emulate.c kvm_x86.c kvm_irq.c kvm_lapic.c kvm_i8254.c kvm_mmu.c kvm_iodev.c kvm_ioapic.c kvm_vmx.c kvm_i8259.c kvm_coalesced_mmio.c kvm_irq_comm.c kvm_cache_regs.c kvm_bitops.c $(HEADERS) kvm_link.c
@./tools/xxxcheck kvm_x86.c kvm.c kvm_irq.c kvm_lapic.c kvm_i8254.c kvm_mmu.c kvm_iodev.c kvm_ioapic.c kvm_vmx.c kvm_i8259.c kvm_coalesced_mmio.c kvm_irq_comm.c kvm_cache_regs.c kvm_bitops.c
@$(HDRCHK) $(HDRCHK_USRFLAG) $(HDRCHK_USRHDRS)
@$(HDRCHK) $(HDRCHK_SYSFLAG) $(HDRCHK_SYSHDRS)
clean:
- @pfexec rm -f *.o kvm
+ @pfexec rm -f *.o kvm kvm.so JOY_kvm_link.so
uninstall:
@pfexec rem_drv kvm || /bin/true
View
59 kvm_link.c
@@ -0,0 +1,59 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2011 Joyent Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#include <devfsadm.h>
+#include <strings.h>
+#include <stdio.h>
+#include <sys/dtrace.h>
+
+static int devfs_kvm_ln(di_minor_t minor, di_node_t node);
+
+/*
+ * The amount of documentation for this format is unsurprisingly limited. There
+ * is probably a better match that we could do. This is modeled off of the
+ * misc_link_i386.c things that we are matching. Like xsvc and its ilk we look
+ * for most ddi_psuedo devices and look for node names that are kvm.
+ */
+static devfsadm_create_t devfs_kvm_create_cbt[] = {
+ { "pseudo", "ddi_pseudo", NULL, TYPE_EXACT, ILEVEL_0, devfs_kvm_ln }
+};
+
+DEVFSADM_CREATE_INIT_V0(devfs_kvm_create_cbt);
+
+static int
+devfs_kvm_ln(di_minor_t minor, di_node_t node)
+{
+ char *mn;
+
+ if (strcmp(di_node_name(node), "kvm") != 0)
+ return (DEVFSADM_CONTINUE);
+
+ mn = di_minor_name(minor);
+ if (mn == NULL)
+ return (DEVFSADM_CONTINUE);
+
+ (void) devfsadm_mklink(mn, node, minor, 0);
+ return (DEVFSADM_CONTINUE);
+}
Please sign in to comment.
Something went wrong with that request. Please try again.