From owner-svn-src-user@FreeBSD.ORG Sun Nov 16 13:57:55 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E69F091A; Sun, 16 Nov 2014 13:57:54 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D33D2B61; Sun, 16 Nov 2014 13:57:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sAGDvsSw002022; Sun, 16 Nov 2014 13:57:54 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sAGDvsWA002020; Sun, 16 Nov 2014 13:57:54 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201411161357.sAGDvsWA002020@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sun, 16 Nov 2014 13:57:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r274584 - in user/dchagin/lemul/sys: compat/linux sys X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2014 13:57:55 -0000 Author: dchagin Date: Sun Nov 16 13:57:53 2014 New Revision: 274584 URL: https://svnweb.freebsd.org/changeset/base/274584 Log: Fix build. Modified: user/dchagin/lemul/sys/compat/linux/linux_misc.c user/dchagin/lemul/sys/sys/syscallsubr.h Modified: user/dchagin/lemul/sys/compat/linux/linux_misc.c ============================================================================== --- user/dchagin/lemul/sys/compat/linux/linux_misc.c Sun Nov 16 09:44:30 2014 (r274583) +++ user/dchagin/lemul/sys/compat/linux/linux_misc.c Sun Nov 16 13:57:53 2014 (r274584) @@ -1975,7 +1975,7 @@ linux_sched_rr_get_interval(struct threa if (tdt == NULL) return (ESRCH); - error = kern_sched_rr_get_interval(td, tdt, &ts); + error = kern_sched_rr_get_interval_td(td, tdt, &ts); if (error != 0) return (error); lts.tv_sec = ts.tv_sec; Modified: user/dchagin/lemul/sys/sys/syscallsubr.h ============================================================================== --- user/dchagin/lemul/sys/sys/syscallsubr.h Sun Nov 16 09:44:30 2014 (r274583) +++ user/dchagin/lemul/sys/sys/syscallsubr.h Sun Nov 16 13:57:53 2014 (r274584) @@ -55,6 +55,7 @@ struct sendfile_args; struct sockaddr; struct stat; struct thr_param; +struct sched_param; struct __wrusage; int kern___getcwd(struct thread *td, u_char *buf, enum uio_seg bufseg, @@ -118,6 +119,10 @@ int kern_jail_get(struct thread *td, str int kern_jail_set(struct thread *td, struct uio *options, int flags); int kern_kevent(struct thread *td, int fd, int nchanges, int nevents, struct kevent_copyops *k_ops, const struct timespec *timeout); +int kern_kevent_fp(struct thread *td, struct file *fp, int nchanges, + int nevents, struct kevent_copyops *k_ops, + const struct timespec *timeout); +int kern_kqueue(struct thread *td, int flags); int kern_kldload(struct thread *td, const char *file, int *fileid); int kern_kldstat(struct thread *td, int fileid, struct kld_file_stat *stat); int kern_kldunload(struct thread *td, int fileid, int flags); @@ -167,8 +172,18 @@ int kern_renameat(struct thread *td, int char *new, enum uio_seg pathseg); int kern_rmdirat(struct thread *td, int fd, char *path, enum uio_seg pathseg); +int kern_sched_getparam(struct thread *td, struct thread *targettd, + struct sched_param *param); +int kern_sched_getscheduler(struct thread *td, struct thread *targettd, + int *policy); +int kern_sched_setparam(struct thread *td, struct thread *targettd, + struct sched_param *param); +int kern_sched_setscheduler(struct thread *td, struct thread *targettd, + int policy, struct sched_param *param); int kern_sched_rr_get_interval(struct thread *td, pid_t pid, struct timespec *ts); +int kern_sched_rr_get_interval_td(struct thread *td, struct thread *targettd, + struct timespec *ts); int kern_semctl(struct thread *td, int semid, int semnum, int cmd, union semun *arg, register_t *rval); int kern_select(struct thread *td, int nd, fd_set *fd_in, fd_set *fd_ou, @@ -212,6 +227,8 @@ int kern_ktimer_settime(struct thread *t int kern_ktimer_gettime(struct thread *td, int timer_id, struct itimerspec *val); int kern_ktimer_getoverrun(struct thread *td, int timer_id); +int kern_thr_alloc(struct proc *, int pages, struct thread **); +int kern_thr_exit(struct thread *td); int kern_thr_new(struct thread *td, struct thr_param *param); int kern_thr_suspend(struct thread *td, struct timespec *tsp); int kern_truncate(struct thread *td, char *path, enum uio_seg pathseg, From owner-svn-src-user@FreeBSD.ORG Fri Nov 21 02:54:12 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E08E2987; Fri, 21 Nov 2014 02:54:12 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B3CD9688; Fri, 21 Nov 2014 02:54:12 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sAL2sC7a006902; Fri, 21 Nov 2014 02:54:12 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sAL2sCmn006901; Fri, 21 Nov 2014 02:54:12 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201411210254.sAL2sCmn006901@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Fri, 21 Nov 2014 02:54:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r274777 - user/marcel/mkimg X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Nov 2014 02:54:13 -0000 Author: marcel Date: Fri Nov 21 02:54:12 2014 New Revision: 274777 URL: https://svnweb.freebsd.org/changeset/base/274777 Log: Remove my WIP branch for mkimg(1). Everything is in head and on stable/10 and there's no major (re-)work on the horizon that would warrant its existence. Deleted: user/marcel/mkimg/ From owner-svn-src-user@FreeBSD.ORG Fri Nov 21 02:56:50 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C8285AA2; Fri, 21 Nov 2014 02:56:50 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9BA346A5; Fri, 21 Nov 2014 02:56:50 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sAL2uonu009001; Fri, 21 Nov 2014 02:56:50 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sAL2uoTl009000; Fri, 21 Nov 2014 02:56:50 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201411210256.sAL2uoTl009000@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Fri, 21 Nov 2014 02:56:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r274778 - user/marcel/libvdsk X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Nov 2014 02:56:50 -0000 Author: marcel Date: Fri Nov 21 02:56:50 2014 New Revision: 274778 URL: https://svnweb.freebsd.org/changeset/base/274778 Log: Create a branch for bootstrapping a library that can read and write virtual disk images. The first consumers of it being bhyveload and bhyve. Yes, the library is called libvdsk. Added: user/marcel/libvdsk/ From owner-svn-src-user@FreeBSD.ORG Fri Nov 21 03:01:33 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A7E6DCCA; Fri, 21 Nov 2014 03:01:33 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 88E578AC; Fri, 21 Nov 2014 03:01:33 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sAL31Xnq014302; Fri, 21 Nov 2014 03:01:33 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sAL31WQW014286; Fri, 21 Nov 2014 03:01:32 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201411210301.sAL31WQW014286@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Fri, 21 Nov 2014 03:01:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r274779 - user/marcel/libvdsk/libvdsk X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Nov 2014 03:01:33 -0000 Author: marcel Date: Fri Nov 21 03:01:31 2014 New Revision: 274779 URL: https://svnweb.freebsd.org/changeset/base/274779 Log: Add libvdsk(3). This has effective enough to handle bhyveload and bhyve in their current (limited) form. Under the hood this will grow support for probing disk image formats and handling them. Added: user/marcel/libvdsk/libvdsk/ user/marcel/libvdsk/libvdsk/Makefile (contents, props changed) user/marcel/libvdsk/libvdsk/vdsk.c (contents, props changed) user/marcel/libvdsk/libvdsk/vdsk.h (contents, props changed) user/marcel/libvdsk/libvdsk/vdsk_int.h (contents, props changed) Added: user/marcel/libvdsk/libvdsk/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/marcel/libvdsk/libvdsk/Makefile Fri Nov 21 03:01:31 2014 (r274779) @@ -0,0 +1,7 @@ +# $FreeBSD$ + +LIB= vdsk +SRCS= vdsk.c +INCS= vdsk.h + +.include Added: user/marcel/libvdsk/libvdsk/vdsk.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/marcel/libvdsk/libvdsk/vdsk.c Fri Nov 21 03:01:31 2014 (r274779) @@ -0,0 +1,150 @@ +/*- + * Copyright (c) 2014 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "vdsk_int.h" + +static struct vdsk * +vdsk_deref(vdskctx ctx) +{ + struct vdsk *vdsk = ctx; + + return (vdsk - 1); +} + +vdskctx +vdsk_open(const char *path, int flags, size_t size) +{ + struct stat sb; + struct vdsk *vdsk; + + size += sizeof(struct vdsk); + vdsk = malloc(size); + if (vdsk == NULL) + return (NULL); + + vdsk->fd = open(path, flags); + if (vdsk->fd == -1) { + free(vdsk); + return (NULL); + } + + if (fstat(vdsk->fd, &sb) == -1) { + close(vdsk->fd); + free(vdsk); + return (NULL); + } + + if (S_ISCHR(sb.st_mode)) { + if (ioctl(vdsk->fd, DIOCGMEDIASIZE, &vdsk->capacity) < 0 || + ioctl(vdsk->fd, DIOCGSECTORSIZE, &vdsk->sectorsize) < 0) { + close(vdsk->fd); + free(vdsk); + return (NULL); + } + } else { + vdsk->capacity = sb.st_size; + vdsk->sectorsize = DEV_BSIZE; + } + return (vdsk + 1); +} + +int +vdsk_close(vdskctx ctx) +{ + struct vdsk *vdsk = vdsk_deref(ctx); + + close(vdsk->fd); + free(vdsk); + return (0); +} + +off_t +vdsk_capacity(vdskctx ctx) +{ + struct vdsk *vdsk = vdsk_deref(ctx); + + return (vdsk->capacity); +} + +int +vdsk_sectorsize(vdskctx ctx) +{ + struct vdsk *vdsk = vdsk_deref(ctx); + + return (vdsk->sectorsize); +} + +ssize_t +vdsk_read(vdskctx ctx, void *buf, size_t nbytes, off_t offset) +{ + struct vdsk *vdsk = vdsk_deref(ctx); + ssize_t res; + + res = pread(vdsk->fd, buf, nbytes, offset); + return (res); +} + +ssize_t +vdsk_readv(vdskctx ctx, const struct iovec *iov, int iovcnt, off_t offset) +{ + struct vdsk *vdsk = vdsk_deref(ctx); + ssize_t res; + + res = preadv(vdsk->fd, iov, iovcnt, offset); + return (res); +} + +ssize_t +vdsk_writev(vdskctx ctx, const struct iovec *iov, int iovcnt, off_t offset) +{ + struct vdsk *vdsk = vdsk_deref(ctx); + ssize_t res; + + res = pwritev(vdsk->fd, iov, iovcnt, offset); + return (res); +} + +int +vdsk_flush(vdskctx ctx __unused) +{ + + return (0); +} + Added: user/marcel/libvdsk/libvdsk/vdsk.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/marcel/libvdsk/libvdsk/vdsk.h Fri Nov 21 03:01:31 2014 (r274779) @@ -0,0 +1,50 @@ +/*- + * Copyright (c) 2014 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef __VDSK_H__ +#define __VDSK_H__ + +#include +#include +#include + +typedef void *vdskctx; + +vdskctx vdsk_open(const char *, int, size_t); +int vdsk_close(vdskctx); + +off_t vdsk_capacity(vdskctx); +int vdsk_sectorsize(vdskctx); + +ssize_t vdsk_read(vdskctx, void *, size_t, off_t); +ssize_t vdsk_readv(vdskctx, const struct iovec *, int, off_t); +ssize_t vdsk_writev(vdskctx, const struct iovec *, int, off_t); + +int vdsk_flush(vdskctx); + +#endif /* __VDSK_H__ */ Added: user/marcel/libvdsk/libvdsk/vdsk_int.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/marcel/libvdsk/libvdsk/vdsk_int.h Fri Nov 21 03:01:31 2014 (r274779) @@ -0,0 +1,38 @@ +/*- + * Copyright (c) 2014 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef __VDSK_INT_H__ +#define __VDSK_INT_H__ + +struct vdsk { + int fd; + int sectorsize; + off_t capacity; +}; + +#endif /* __VDSK_INT_H__ */ From owner-svn-src-user@FreeBSD.ORG Fri Nov 21 03:03:33 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BD113E47; Fri, 21 Nov 2014 03:03:33 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 914938BD; Fri, 21 Nov 2014 03:03:33 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sAL33XjZ018800; Fri, 21 Nov 2014 03:03:33 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sAL33XuD018799; Fri, 21 Nov 2014 03:03:33 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201411210303.sAL33XuD018799@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Fri, 21 Nov 2014 03:03:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r274780 - user/marcel/libvdsk/bhyve X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Nov 2014 03:03:33 -0000 Author: marcel Date: Fri Nov 21 03:03:33 2014 New Revision: 274780 URL: https://svnweb.freebsd.org/changeset/base/274780 Log: Branch head/usr.sbin/bhyve Added: - copied from r274779, head/usr.sbin/bhyve/ Directory Properties: user/marcel/libvdsk/bhyve/ (props changed) From owner-svn-src-user@FreeBSD.ORG Fri Nov 21 03:04:12 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B124EF4C; Fri, 21 Nov 2014 03:04:12 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 84B2F8BF; Fri, 21 Nov 2014 03:04:12 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sAL34Cjo019361; Fri, 21 Nov 2014 03:04:12 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sAL34CJI019359; Fri, 21 Nov 2014 03:04:12 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201411210304.sAL34CJI019359@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Fri, 21 Nov 2014 03:04:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r274781 - user/marcel/libvdsk/bhyveload X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Nov 2014 03:04:12 -0000 Author: marcel Date: Fri Nov 21 03:04:11 2014 New Revision: 274781 URL: https://svnweb.freebsd.org/changeset/base/274781 Log: Branch head/usr.sbin/bhyveload Added: - copied from r274780, head/usr.sbin/bhyveload/ Directory Properties: user/marcel/libvdsk/bhyveload/ (props changed) From owner-svn-src-user@FreeBSD.ORG Fri Nov 21 03:19:52 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 126803B0; Fri, 21 Nov 2014 03:19:52 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F31889E8; Fri, 21 Nov 2014 03:19:51 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sAL3Jpbm034813; Fri, 21 Nov 2014 03:19:51 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sAL3JpeH034808; Fri, 21 Nov 2014 03:19:51 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201411210319.sAL3JpeH034808@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Fri, 21 Nov 2014 03:19:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r274782 - in user/marcel/libvdsk: bhyve bhyveload X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Nov 2014 03:19:52 -0000 Author: marcel Date: Fri Nov 21 03:19:51 2014 New Revision: 274782 URL: https://svnweb.freebsd.org/changeset/base/274782 Log: Build this outside a FreeBSD tree. Assume /sys works for us. Modified: user/marcel/libvdsk/bhyve/Makefile user/marcel/libvdsk/bhyveload/Makefile Modified: user/marcel/libvdsk/bhyve/Makefile ============================================================================== --- user/marcel/libvdsk/bhyve/Makefile Fri Nov 21 03:04:11 2014 (r274781) +++ user/marcel/libvdsk/bhyve/Makefile Fri Nov 21 03:19:51 2014 (r274782) @@ -40,7 +40,7 @@ SRCS= \ xmsr.c \ spinup_ap.c -.PATH: ${.CURDIR}/../../sys/amd64/vmm +.PATH: /sys/amd64/vmm SRCS+= vmm_instruction_emul.c DPADD= ${LIBVMMAPI} ${LIBMD} ${LIBUTIL} ${LIBPTHREAD} Modified: user/marcel/libvdsk/bhyveload/Makefile ============================================================================== --- user/marcel/libvdsk/bhyveload/Makefile Fri Nov 21 03:04:11 2014 (r274781) +++ user/marcel/libvdsk/bhyveload/Makefile Fri Nov 21 03:19:51 2014 (r274782) @@ -9,6 +9,6 @@ LDADD+= -lvmmapi -lutil WARNS?= 3 -CFLAGS+=-I${.CURDIR}/../../sys/boot/userboot +CFLAGS+=-I/sys/boot/userboot .include From owner-svn-src-user@FreeBSD.ORG Fri Nov 21 03:22:23 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 91E4450B; Fri, 21 Nov 2014 03:22:23 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7E896A8B; Fri, 21 Nov 2014 03:22:23 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sAL3MNwQ040225; Fri, 21 Nov 2014 03:22:23 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sAL3MMsk040209; Fri, 21 Nov 2014 03:22:22 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201411210322.sAL3MMsk040209@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Fri, 21 Nov 2014 03:22:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r274783 - in user/marcel/libvdsk: bhyve bhyveload X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Nov 2014 03:22:23 -0000 Author: marcel Date: Fri Nov 21 03:22:22 2014 New Revision: 274783 URL: https://svnweb.freebsd.org/changeset/base/274783 Log: Use libvdsk(3) to implement block devices. Modified: user/marcel/libvdsk/bhyve/Makefile user/marcel/libvdsk/bhyve/block_if.c user/marcel/libvdsk/bhyveload/Makefile user/marcel/libvdsk/bhyveload/bhyveload.c Modified: user/marcel/libvdsk/bhyve/Makefile ============================================================================== --- user/marcel/libvdsk/bhyve/Makefile Fri Nov 21 03:19:51 2014 (r274782) +++ user/marcel/libvdsk/bhyve/Makefile Fri Nov 21 03:22:22 2014 (r274783) @@ -43,8 +43,8 @@ SRCS= \ .PATH: /sys/amd64/vmm SRCS+= vmm_instruction_emul.c -DPADD= ${LIBVMMAPI} ${LIBMD} ${LIBUTIL} ${LIBPTHREAD} -LDADD= -lvmmapi -lmd -lutil -lpthread +DPADD= ${LIBVDSK} ${LIBVMMAPI} ${LIBMD} ${LIBUTIL} ${LIBPTHREAD} +LDADD= -lvdsk -lvmmapi -lmd -lutil -lpthread WARNS?= 2 Modified: user/marcel/libvdsk/bhyve/block_if.c ============================================================================== --- user/marcel/libvdsk/bhyve/block_if.c Fri Nov 21 03:19:51 2014 (r274782) +++ user/marcel/libvdsk/bhyve/block_if.c Fri Nov 21 03:22:22 2014 (r274783) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -79,10 +80,7 @@ struct blockif_elem { struct blockif_ctxt { int bc_magic; - int bc_fd; int bc_rdonly; - off_t bc_size; - int bc_sectsz; pthread_t bc_btid; pthread_mutex_t bc_mtx; pthread_cond_t bc_cond; @@ -176,18 +174,17 @@ blockif_proc(struct blockif_ctxt *bc, st switch (be->be_op) { case BOP_READ: - if (preadv(bc->bc_fd, br->br_iov, br->br_iovcnt, - br->br_offset) < 0) + if (vdsk_readv(bc, br->br_iov, br->br_iovcnt, + br->br_offset) < 0) err = errno; break; case BOP_WRITE: - if (bc->bc_rdonly) - err = EROFS; - else if (pwritev(bc->bc_fd, br->br_iov, br->br_iovcnt, - br->br_offset) < 0) + if (vdsk_writev(bc, br->br_iov, br->br_iovcnt, + br->br_offset) < 0) err = errno; break; case BOP_FLUSH: + err = vdsk_flush(bc); break; default: err = EINVAL; @@ -267,9 +264,7 @@ blockif_open(const char *optstr, const c char tname[MAXCOMLEN + 1]; char *nopt, *xopts; struct blockif_ctxt *bc; - struct stat sbuf; - off_t size; - int extra, fd, i, sectsz; + int extra, i; int nocache, sync, ro; pthread_once(&blockif_once, blockif_init); @@ -300,51 +295,20 @@ blockif_open(const char *optstr, const c if (sync) extra |= O_SYNC; - fd = open(nopt, (ro ? O_RDONLY : O_RDWR) | extra); - if (fd < 0 && !ro) { + bc = vdsk_open(nopt, (ro ? O_RDONLY : O_RDWR) | extra, sizeof(*bc)); + if (bc == NULL && !ro) { /* Attempt a r/w fail with a r/o open */ - fd = open(nopt, O_RDONLY | extra); + bc = vdsk_open(nopt, O_RDONLY | extra, sizeof(*bc)); ro = 1; } - if (fd < 0) { - perror("Could not open backing file"); - return (NULL); - } - - if (fstat(fd, &sbuf) < 0) { - perror("Could not stat backing file"); - close(fd); - return (NULL); - } - - /* - * Deal with raw devices - */ - size = sbuf.st_size; - sectsz = DEV_BSIZE; - if (S_ISCHR(sbuf.st_mode)) { - if (ioctl(fd, DIOCGMEDIASIZE, &size) < 0 || - ioctl(fd, DIOCGSECTORSIZE, §sz)) { - perror("Could not fetch dev blk/sector size"); - close(fd); - return (NULL); - } - assert(size != 0); - assert(sectsz != 0); - } - - bc = calloc(1, sizeof(struct blockif_ctxt)); if (bc == NULL) { - close(fd); + perror("Could not open backing file"); return (NULL); } bc->bc_magic = BLOCKIF_SIG; - bc->bc_fd = fd; bc->bc_rdonly = ro; - bc->bc_size = size; - bc->bc_sectsz = sectsz; pthread_mutex_init(&bc->bc_mtx, NULL); pthread_cond_init(&bc->bc_cond, NULL); TAILQ_INIT(&bc->bc_freeq); @@ -521,8 +485,7 @@ blockif_close(struct blockif_ctxt *bc) * Release resources */ bc->bc_magic = 0; - close(bc->bc_fd); - free(bc); + vdsk_close(bc); return (0); } @@ -541,7 +504,7 @@ blockif_chs(struct blockif_ctxt *bc, uin assert(bc->bc_magic == BLOCKIF_SIG); - sectors = bc->bc_size / bc->bc_sectsz; + sectors = vdsk_capacity(bc) / vdsk_sectorsize(bc); /* Clamp the size to the largest possible with CHS */ if (sectors > 65535UL*16*255) @@ -584,7 +547,7 @@ blockif_size(struct blockif_ctxt *bc) { assert(bc->bc_magic == BLOCKIF_SIG); - return (bc->bc_size); + return (vdsk_capacity(bc)); } int @@ -592,7 +555,7 @@ blockif_sectsz(struct blockif_ctxt *bc) { assert(bc->bc_magic == BLOCKIF_SIG); - return (bc->bc_sectsz); + return (vdsk_sectorsize(bc)); } int Modified: user/marcel/libvdsk/bhyveload/Makefile ============================================================================== --- user/marcel/libvdsk/bhyveload/Makefile Fri Nov 21 03:19:51 2014 (r274782) +++ user/marcel/libvdsk/bhyveload/Makefile Fri Nov 21 03:22:22 2014 (r274783) @@ -4,8 +4,8 @@ PROG= bhyveload SRCS= bhyveload.c MAN= bhyveload.8 -DPADD+= ${LIBVMMAPI} ${LIBUTIL} -LDADD+= -lvmmapi -lutil +DPADD+= ${LIBVDSK} ${LIBVMMAPI} ${LIBUTIL} +LDADD+= -lvdsk -lvmmapi -lutil WARNS?= 3 Modified: user/marcel/libvdsk/bhyveload/bhyveload.c ============================================================================== --- user/marcel/libvdsk/bhyveload/bhyveload.c Fri Nov 21 03:19:51 2014 (r274782) +++ user/marcel/libvdsk/bhyveload/bhyveload.c Fri Nov 21 03:22:22 2014 (r274783) @@ -79,7 +79,7 @@ __FBSDID("$FreeBSD$"); #include #include #include - +#include #include #include "userboot.h" @@ -92,7 +92,7 @@ __FBSDID("$FreeBSD$"); static char *host_base; static struct termios term, oldterm; -static int disk_fd[NDISKS]; +static vdskctx disk[NDISKS]; static int ndisks; static int consin_fd, consout_fd; @@ -290,9 +290,9 @@ cb_diskread(void *arg, int unit, uint64_ { ssize_t n; - if (unit < 0 || unit >= ndisks ) + if (unit < 0 || unit >= ndisks) return (EIO); - n = pread(disk_fd[unit], to, size, from); + n = vdsk_read(disk[unit], to, size, from); if (n < 0) return (errno); *resid = size - n; @@ -302,20 +302,16 @@ cb_diskread(void *arg, int unit, uint64_ static int cb_diskioctl(void *arg, int unit, u_long cmd, void *data) { - struct stat sb; if (unit < 0 || unit >= ndisks) return (EBADF); switch (cmd) { case DIOCGSECTORSIZE: - *(u_int *)data = 512; + *(u_int *)data = vdsk_sectorsize(disk[unit]); break; case DIOCGMEDIASIZE: - if (fstat(disk_fd[unit], &sb) == 0) - *(off_t *)data = sb.st_size; - else - return (ENOTTY); + *(off_t *)data = vdsk_capacity(disk[unit]); break; default: return (ENOTTY); @@ -607,21 +603,17 @@ altcons_open(char *path) static int disk_open(char *path) { - int err, fd; + vdskctx vdsk; - if (ndisks > NDISKS) + if (ndisks >= NDISKS) return (ERANGE); - err = 0; - fd = open(path, O_RDONLY); - - if (fd > 0) { - disk_fd[ndisks] = fd; - ndisks++; - } else - err = errno; + vdsk = vdsk_open(path, O_RDONLY, 0); + if (vdsk == NULL) + return (errno); - return (err); + disk[ndisks++] = vdsk; + return (0); } static void From owner-svn-src-user@FreeBSD.ORG Fri Nov 21 16:22:02 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BA4F5A04; Fri, 21 Nov 2014 16:22:02 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A799977E; Fri, 21 Nov 2014 16:22:02 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sALGM2mW096759; Fri, 21 Nov 2014 16:22:02 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sALGM2P4096758; Fri, 21 Nov 2014 16:22:02 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201411211622.sALGM2P4096758@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Fri, 21 Nov 2014 16:22:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r274798 - user/marcel/libvdsk X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Nov 2014 16:22:02 -0000 Author: marcel Date: Fri Nov 21 16:22:01 2014 New Revision: 274798 URL: https://svnweb.freebsd.org/changeset/base/274798 Log: Add a top-level directory to make libvdsk, bhyve and bhyveload. Added: user/marcel/libvdsk/Makefile (contents, props changed) Added: user/marcel/libvdsk/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/marcel/libvdsk/Makefile Fri Nov 21 16:22:01 2014 (r274798) @@ -0,0 +1,5 @@ +# $FreeBSD$ + +SUBDIR= libvdsk bhyve bhyveload + +.include From owner-svn-src-user@FreeBSD.ORG Fri Nov 21 16:32:00 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 86100DB2; Fri, 21 Nov 2014 16:32:00 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 732F1891; Fri, 21 Nov 2014 16:32:00 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sALGW0Zq005820; Fri, 21 Nov 2014 16:32:00 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sALGW0Bh005819; Fri, 21 Nov 2014 16:32:00 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201411211632.sALGW0Bh005819@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Fri, 21 Nov 2014 16:32:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r274799 - user/marcel/libvdsk X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Nov 2014 16:32:00 -0000 Author: marcel Date: Fri Nov 21 16:31:59 2014 New Revision: 274799 URL: https://svnweb.freebsd.org/changeset/base/274799 Log: Add build glue for when libvdsk is not installed on the system. Added: user/marcel/libvdsk/Makefile.inc (contents, props changed) Added: user/marcel/libvdsk/Makefile.inc ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/marcel/libvdsk/Makefile.inc Fri Nov 21 16:31:59 2014 (r274799) @@ -0,0 +1,5 @@ +# $FreeBSD$ + +CFLAGS+=-I${.CURDIR}/../libvdsk +LDFLAGS+=-L${.OBJDIR}/../libvdsk +LIBVDSK?=${.OBJDIR}/../libvdsk/libvdsk.a From owner-svn-src-user@FreeBSD.ORG Fri Nov 21 17:23:16 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 06A39BF5; Fri, 21 Nov 2014 17:23:16 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E7D38E93; Fri, 21 Nov 2014 17:23:15 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sALHNFA0050175; Fri, 21 Nov 2014 17:23:15 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sALHNFIv050174; Fri, 21 Nov 2014 17:23:15 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201411211723.sALHNFIv050174@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Fri, 21 Nov 2014 17:23:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r274801 - user/marcel/libvdsk X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Nov 2014 17:23:16 -0000 Author: marcel Date: Fri Nov 21 17:23:15 2014 New Revision: 274801 URL: https://svnweb.freebsd.org/changeset/base/274801 Log: Make sure to provide defaults for BINDIR, SHLIB_MAJOR and WARNS. These come from lib/Makefile.inc and usr.sbin/Makefile.inc in the FreeBSD source tree. Things don't quite work the same without them. While here again: columnize. Modified: user/marcel/libvdsk/Makefile.inc Modified: user/marcel/libvdsk/Makefile.inc ============================================================================== --- user/marcel/libvdsk/Makefile.inc Fri Nov 21 17:08:28 2014 (r274800) +++ user/marcel/libvdsk/Makefile.inc Fri Nov 21 17:23:15 2014 (r274801) @@ -1,5 +1,9 @@ # $FreeBSD$ -CFLAGS+=-I${.CURDIR}/../libvdsk -LDFLAGS+=-L${.OBJDIR}/../libvdsk -LIBVDSK?=${.OBJDIR}/../libvdsk/libvdsk.a +CFLAGS += -I${.CURDIR}/../libvdsk +LDFLAGS += -L${.OBJDIR}/../libvdsk +LIBVDSK ?= ${.OBJDIR}/../libvdsk/libvdsk.a + +BINDIR ?= /usr/sbin +SHLIB_MAJOR ?= 5 +WARNS ?= 6 From owner-svn-src-user@FreeBSD.ORG Fri Nov 21 18:35:51 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8416ABFE; Fri, 21 Nov 2014 18:35:51 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 71D45908; Fri, 21 Nov 2014 18:35:51 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sALIZpXE012780; Fri, 21 Nov 2014 18:35:51 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sALIZp3B012778; Fri, 21 Nov 2014 18:35:51 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201411211835.sALIZp3B012778@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Fri, 21 Nov 2014 18:35:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r274808 - user/marcel/libvdsk/libvdsk X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Nov 2014 18:35:51 -0000 Author: marcel Date: Fri Nov 21 18:35:50 2014 New Revision: 274808 URL: https://svnweb.freebsd.org/changeset/base/274808 Log: Make sure struct vdsk is a multiple of 16 bytes so that the user data is always sufficiently aligned. Modified: user/marcel/libvdsk/libvdsk/vdsk_int.h Modified: user/marcel/libvdsk/libvdsk/vdsk_int.h ============================================================================== --- user/marcel/libvdsk/libvdsk/vdsk_int.h Fri Nov 21 18:35:48 2014 (r274807) +++ user/marcel/libvdsk/libvdsk/vdsk_int.h Fri Nov 21 18:35:50 2014 (r274808) @@ -33,6 +33,6 @@ struct vdsk { int fd; int sectorsize; off_t capacity; -}; +} __attribute__((align(16))); #endif /* __VDSK_INT_H__ */ From owner-svn-src-user@FreeBSD.ORG Fri Nov 21 19:13:56 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id ADC3B6AE; Fri, 21 Nov 2014 19:13:56 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 80828D07; Fri, 21 Nov 2014 19:13:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sALJDtGS046088; Fri, 21 Nov 2014 19:13:55 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sALJDtHm046087; Fri, 21 Nov 2014 19:13:55 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201411211913.sALJDtHm046087@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Fri, 21 Nov 2014 19:13:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r274809 - user/marcel/libvdsk/libvdsk X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Nov 2014 19:13:56 -0000 Author: marcel Date: Fri Nov 21 19:13:54 2014 New Revision: 274809 URL: https://svnweb.freebsd.org/changeset/base/274809 Log: Improve vdsk_open(): 1. Use calloc(3) instead of malloc(3) so that the user context is always pre-initialized. 2. Wrap the sequence of steps in a `do { ... } while (0)' block so that we can use break to exit. Introduce ctx as the variable to return and use it to determine success or failure. With a single entry and a single exit, we can more easily add some kind of tracing or logging in the future. Modified: user/marcel/libvdsk/libvdsk/vdsk.c Modified: user/marcel/libvdsk/libvdsk/vdsk.c ============================================================================== --- user/marcel/libvdsk/libvdsk/vdsk.c Fri Nov 21 18:35:50 2014 (r274808) +++ user/marcel/libvdsk/libvdsk/vdsk.c Fri Nov 21 19:13:54 2014 (r274809) @@ -52,37 +52,50 @@ vdskctx vdsk_open(const char *path, int flags, size_t size) { struct stat sb; + vdskctx ctx; struct vdsk *vdsk; - size += sizeof(struct vdsk); - vdsk = malloc(size); - if (vdsk == NULL) - return (NULL); - - vdsk->fd = open(path, flags); - if (vdsk->fd == -1) { - free(vdsk); - return (NULL); - } + ctx = NULL; - if (fstat(vdsk->fd, &sb) == -1) { - close(vdsk->fd); - free(vdsk); - return (NULL); - } + do { + size += sizeof(struct vdsk); + vdsk = calloc(1, size); + if (vdsk == NULL) + break; + + vdsk->fd = open(path, flags); + if (vdsk->fd == -1) + break; + + if (fstat(vdsk->fd, &sb) == -1) + break; + + if (S_ISCHR(sb.st_mode)) { + if (ioctl(vdsk->fd, DIOCGMEDIASIZE, + &vdsk->capacity) < 0) + break; + if (ioctl(vdsk->fd, DIOCGSECTORSIZE, + &vdsk->sectorsize) < 0) + break; + } else { + vdsk->capacity = sb.st_size; + vdsk->sectorsize = DEV_BSIZE; + } - if (S_ISCHR(sb.st_mode)) { - if (ioctl(vdsk->fd, DIOCGMEDIASIZE, &vdsk->capacity) < 0 || - ioctl(vdsk->fd, DIOCGSECTORSIZE, &vdsk->sectorsize) < 0) { - close(vdsk->fd); + /* Complete... */ + ctx = vdsk + 1; + } while (0); + + if (ctx == NULL) { + if (vdsk != NULL) { + if (vdsk->fd != -1) + close(vdsk->fd); free(vdsk); - return (NULL); + vdsk = NULL; } - } else { - vdsk->capacity = sb.st_size; - vdsk->sectorsize = DEV_BSIZE; } - return (vdsk + 1); + + return (ctx); } int From owner-svn-src-user@FreeBSD.ORG Fri Nov 21 19:19:28 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A0EEF8C0; Fri, 21 Nov 2014 19:19:28 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8DE83D41; Fri, 21 Nov 2014 19:19:28 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sALJJSTp048656; Fri, 21 Nov 2014 19:19:28 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sALJJSmP048655; Fri, 21 Nov 2014 19:19:28 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201411211919.sALJJSmP048655@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Fri, 21 Nov 2014 19:19:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r274810 - user/marcel/libvdsk/bhyve X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Nov 2014 19:19:28 -0000 Author: marcel Date: Fri Nov 21 19:19:27 2014 New Revision: 274810 URL: https://svnweb.freebsd.org/changeset/base/274810 Log: Remove redundant FreeBSD keyword. Modified: user/marcel/libvdsk/bhyve/block_if.c Modified: user/marcel/libvdsk/bhyve/block_if.c ============================================================================== --- user/marcel/libvdsk/bhyve/block_if.c Fri Nov 21 19:13:54 2014 (r274809) +++ user/marcel/libvdsk/bhyve/block_if.c Fri Nov 21 19:19:27 2014 (r274810) @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #include From owner-svn-src-user@FreeBSD.ORG Fri Nov 21 19:40:22 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 34BD2DCE; Fri, 21 Nov 2014 19:40:22 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 220BAF42; Fri, 21 Nov 2014 19:40:22 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sALJeLXd066311; Fri, 21 Nov 2014 19:40:22 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sALJeLLH066310; Fri, 21 Nov 2014 19:40:21 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201411211940.sALJeLLH066310@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Fri, 21 Nov 2014 19:40:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r274811 - user/marcel/libvdsk/libvdsk X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Nov 2014 19:40:22 -0000 Author: marcel Date: Fri Nov 21 19:40:21 2014 New Revision: 274811 URL: https://svnweb.freebsd.org/changeset/base/274811 Log: Implement vdsk_flush() as is done in pci_virtio_block.c. Modified: user/marcel/libvdsk/libvdsk/vdsk.c Modified: user/marcel/libvdsk/libvdsk/vdsk.c ============================================================================== --- user/marcel/libvdsk/libvdsk/vdsk.c Fri Nov 21 19:19:27 2014 (r274810) +++ user/marcel/libvdsk/libvdsk/vdsk.c Fri Nov 21 19:40:21 2014 (r274811) @@ -155,9 +155,12 @@ vdsk_writev(vdskctx ctx, const struct io } int -vdsk_flush(vdskctx ctx __unused) +vdsk_flush(vdskctx ctx) { + struct vdsk *vdsk = vdsk_deref(ctx); + int res; - return (0); + res = fsync(vdsk->fd); + return ((res == -1) ? errno : 0); } From owner-svn-src-user@FreeBSD.ORG Fri Nov 21 19:41:14 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 06516EF1; Fri, 21 Nov 2014 19:41:14 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E7626FDB; Fri, 21 Nov 2014 19:41:13 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sALJfDCR067421; Fri, 21 Nov 2014 19:41:13 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sALJfDZK067420; Fri, 21 Nov 2014 19:41:13 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201411211941.sALJfDZK067420@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Fri, 21 Nov 2014 19:41:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r274812 - user/marcel/libvdsk/libvdsk X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Nov 2014 19:41:14 -0000 Author: marcel Date: Fri Nov 21 19:41:13 2014 New Revision: 274812 URL: https://svnweb.freebsd.org/changeset/base/274812 Log: o Use major version 0. We're bootstrapping... o Build for debugging... Modified: user/marcel/libvdsk/libvdsk/Makefile Modified: user/marcel/libvdsk/libvdsk/Makefile ============================================================================== --- user/marcel/libvdsk/libvdsk/Makefile Fri Nov 21 19:40:21 2014 (r274811) +++ user/marcel/libvdsk/libvdsk/Makefile Fri Nov 21 19:41:13 2014 (r274812) @@ -1,7 +1,11 @@ # $FreeBSD$ LIB= vdsk +SHLIB_MAJOR= 0 + SRCS= vdsk.c INCS= vdsk.h +DEBUG_FLAGS=-O0 -gdwarf-2 + .include From owner-svn-src-user@FreeBSD.ORG Fri Nov 21 19:42:56 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EF03E16F; Fri, 21 Nov 2014 19:42:56 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DC0D828; Fri, 21 Nov 2014 19:42:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sALJgupP070478; Fri, 21 Nov 2014 19:42:56 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sALJgud9070477; Fri, 21 Nov 2014 19:42:56 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201411211942.sALJgud9070477@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Fri, 21 Nov 2014 19:42:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r274813 - user/marcel/libvdsk/bhyve X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Nov 2014 19:42:57 -0000 Author: marcel Date: Fri Nov 21 19:42:56 2014 New Revision: 274813 URL: https://svnweb.freebsd.org/changeset/base/274813 Log: Commit the kluge to make bhyve work in VMware Fusion on Mac OS X. I don't want to keep it as a modified file in my sandbox. Modified: user/marcel/libvdsk/bhyve/xmsr.c Modified: user/marcel/libvdsk/bhyve/xmsr.c ============================================================================== --- user/marcel/libvdsk/bhyve/xmsr.c Fri Nov 21 19:41:13 2014 (r274812) +++ user/marcel/libvdsk/bhyve/xmsr.c Fri Nov 21 19:42:56 2014 (r274813) @@ -49,6 +49,9 @@ int emulate_wrmsr(struct vmctx *ctx, int vcpu, uint32_t num, uint64_t val) { + if (num == MSR_PAT) + return 0; + if (cpu_vendor_intel) { switch (num) { case 0xd04: /* Sandy Bridge uncore PMCs */ From owner-svn-src-user@FreeBSD.ORG Fri Nov 21 19:44:28 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7A273371; Fri, 21 Nov 2014 19:44:28 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 66D2981; Fri, 21 Nov 2014 19:44:28 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sALJiSMB071352; Fri, 21 Nov 2014 19:44:28 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sALJiSmp071351; Fri, 21 Nov 2014 19:44:28 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201411211944.sALJiSmp071351@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Fri, 21 Nov 2014 19:44:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r274814 - user/marcel/libvdsk/bhyve X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Nov 2014 19:44:28 -0000 Author: marcel Date: Fri Nov 21 19:44:27 2014 New Revision: 274814 URL: https://svnweb.freebsd.org/changeset/base/274814 Log: Port to libvdsk(3). This also removes duplication between this file and block_if.c. Modified: user/marcel/libvdsk/bhyve/pci_virtio_block.c Modified: user/marcel/libvdsk/bhyve/pci_virtio_block.c ============================================================================== --- user/marcel/libvdsk/bhyve/pci_virtio_block.c Fri Nov 21 19:42:56 2014 (r274813) +++ user/marcel/libvdsk/bhyve/pci_virtio_block.c Fri Nov 21 19:44:27 2014 (r274814) @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #include @@ -47,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "bhyverun.h" #include "pci_emul.h" @@ -117,7 +116,6 @@ struct pci_vtblk_softc { struct virtio_softc vbsc_vs; pthread_mutex_t vsc_mtx; struct vqueue_info vbsc_vq; - int vbsc_fd; struct vtblk_config vbsc_cfg; char vbsc_ident[VTBLK_BLK_ID_BYTES]; }; @@ -206,36 +204,37 @@ pci_vtblk_proc(struct pci_vtblk_softc *s DPRINTF(("virtio-block: %s op, %d bytes, %d segs, offset %ld\n\r", writeop ? "write" : "read/ident", iolen, i - 1, offset)); + err = 0; + switch (type) { case VBH_OP_WRITE: - err = pwritev(sc->vbsc_fd, iov + 1, i - 1, offset); + if (vdsk_writev(sc, iov + 1, i - 1, offset) == -1) + err = errno; break; case VBH_OP_READ: - err = preadv(sc->vbsc_fd, iov + 1, i - 1, offset); + if (vdsk_readv(sc, iov + 1, i - 1, offset) == -1) + err = errno; break; case VBH_OP_IDENT: /* Assume a single buffer */ strlcpy(iov[1].iov_base, sc->vbsc_ident, MIN(iov[1].iov_len, sizeof(sc->vbsc_ident))); - err = 0; break; case VBH_OP_FLUSH: case VBH_OP_FLUSH_OUT: - err = fsync(sc->vbsc_fd); + err = vdsk_flush(sc); break; default: - err = -ENOSYS; + err = ENOSYS; break; } /* convert errno into a virtio block error return */ - if (err < 0) { - if (err == -ENOSYS) - *status = VTBLK_S_UNSUPP; - else - *status = VTBLK_S_IOERR; - } else - *status = VTBLK_S_OK; + switch (err) { + case 0: *status = VTBLK_S_OK; break; + case ENOSYS: *status = VTBLK_S_UNSUPP; break; + default: *status = VTBLK_S_IOERR; break; + } /* * Return the descriptor back to the host. @@ -258,55 +257,21 @@ pci_vtblk_notify(void *vsc, struct vqueu static int pci_vtblk_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) { - struct stat sbuf; MD5_CTX mdctx; u_char digest[16]; struct pci_vtblk_softc *sc; - off_t size; - int fd; - int sectsz; if (opts == NULL) { printf("virtio-block: backing device required\n"); return (1); } - /* - * The supplied backing file has to exist - */ - fd = open(opts, O_RDWR); - if (fd < 0) { + sc = vdsk_open(opts, O_RDWR, sizeof(*sc)); + if (sc == NULL) { perror("Could not open backing file"); return (1); } - if (fstat(fd, &sbuf) < 0) { - perror("Could not stat backing file"); - close(fd); - return (1); - } - - /* - * Deal with raw devices - */ - size = sbuf.st_size; - sectsz = DEV_BSIZE; - if (S_ISCHR(sbuf.st_mode)) { - if (ioctl(fd, DIOCGMEDIASIZE, &size) < 0 || - ioctl(fd, DIOCGSECTORSIZE, §sz)) { - perror("Could not fetch dev blk/sector size"); - close(fd); - return (1); - } - assert(size != 0); - assert(sectsz != 0); - } - - sc = calloc(1, sizeof(struct pci_vtblk_softc)); - - /* record fd of storage device/file */ - sc->vbsc_fd = fd; - pthread_mutex_init(&sc->vsc_mtx, NULL); /* init virtio softc and virtqueues */ @@ -327,9 +292,9 @@ pci_vtblk_init(struct vmctx *ctx, struct digest[0], digest[1], digest[2], digest[3], digest[4], digest[5]); /* setup virtio block config space */ - sc->vbsc_cfg.vbc_capacity = size / DEV_BSIZE; /* 512-byte units */ + sc->vbsc_cfg.vbc_capacity = vdsk_capacity(sc) / DEV_BSIZE; sc->vbsc_cfg.vbc_seg_max = VTBLK_MAXSEGS; - sc->vbsc_cfg.vbc_blk_size = sectsz; + sc->vbsc_cfg.vbc_blk_size = vdsk_sectorsize(sc); sc->vbsc_cfg.vbc_size_max = 0; /* not negotiated */ sc->vbsc_cfg.vbc_geom_c = 0; /* no geometry */ sc->vbsc_cfg.vbc_geom_h = 0; From owner-svn-src-user@FreeBSD.ORG Sat Nov 22 02:44:41 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1929097D; Sat, 22 Nov 2014 02:44:41 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EE7FEF9F; Sat, 22 Nov 2014 02:44:40 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sAM2ie9v019706; Sat, 22 Nov 2014 02:44:40 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sAM2iex0019702; Sat, 22 Nov 2014 02:44:40 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201411220244.sAM2iex0019702@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Sat, 22 Nov 2014 02:44:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r274838 - user/marcel/libvdsk/libvdsk X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Nov 2014 02:44:41 -0000 Author: marcel Date: Sat Nov 22 02:44:39 2014 New Revision: 274838 URL: https://svnweb.freebsd.org/changeset/base/274838 Log: Strengthen vdsk_open: 1. Save the realpath(3) result in the vdsk structure. 2. Save the stat(2) result in the vdsk structure. 3. Take an exclusive or shared lock depending on the open flags. Modified: user/marcel/libvdsk/libvdsk/vdsk.c user/marcel/libvdsk/libvdsk/vdsk_int.h Modified: user/marcel/libvdsk/libvdsk/vdsk.c ============================================================================== --- user/marcel/libvdsk/libvdsk/vdsk.c Sat Nov 22 01:27:45 2014 (r274837) +++ user/marcel/libvdsk/libvdsk/vdsk.c Sat Nov 22 02:44:39 2014 (r274838) @@ -51,9 +51,9 @@ vdsk_deref(vdskctx ctx) vdskctx vdsk_open(const char *path, int flags, size_t size) { - struct stat sb; vdskctx ctx; struct vdsk *vdsk; + int lck; ctx = NULL; @@ -63,14 +63,25 @@ vdsk_open(const char *path, int flags, s if (vdsk == NULL) break; - vdsk->fd = open(path, flags); + vdsk->fflags = flags + 1; + if ((vdsk->fflags & ~(O_ACCMODE | O_DIRECT | O_SYNC)) != 0) { + errno = EINVAL; + break; + } + + vdsk->filename = realpath(path, NULL); + if (vdsk->filename == NULL) + break; + + flags = (flags & O_ACCMODE) | O_CLOEXEC; + vdsk->fd = open(vdsk->filename, flags); if (vdsk->fd == -1) break; - if (fstat(vdsk->fd, &sb) == -1) + if (fstat(vdsk->fd, &vdsk->fsbuf) == -1) break; - if (S_ISCHR(sb.st_mode)) { + if (S_ISCHR(vdsk->fsbuf.st_mode)) { if (ioctl(vdsk->fd, DIOCGMEDIASIZE, &vdsk->capacity) < 0) break; @@ -78,10 +89,14 @@ vdsk_open(const char *path, int flags, s &vdsk->sectorsize) < 0) break; } else { - vdsk->capacity = sb.st_size; + vdsk->capacity = vdsk->fsbuf.st_size; vdsk->sectorsize = DEV_BSIZE; } + lck = (vdsk->fflags & FWRITE) ? LOCK_EX : LOCK_SH; + if (flock(vdsk->fd, lck | LOCK_NB) == -1) + break; + /* Complete... */ ctx = vdsk + 1; } while (0); @@ -90,8 +105,9 @@ vdsk_open(const char *path, int flags, s if (vdsk != NULL) { if (vdsk->fd != -1) close(vdsk->fd); + if (vdsk->filename != NULL) + free(vdsk->filename); free(vdsk); - vdsk = NULL; } } @@ -103,7 +119,9 @@ vdsk_close(vdskctx ctx) { struct vdsk *vdsk = vdsk_deref(ctx); + flock(vdsk->fd, LOCK_UN); close(vdsk->fd); + free(vdsk->filename); free(vdsk); return (0); } Modified: user/marcel/libvdsk/libvdsk/vdsk_int.h ============================================================================== --- user/marcel/libvdsk/libvdsk/vdsk_int.h Sat Nov 22 01:27:45 2014 (r274837) +++ user/marcel/libvdsk/libvdsk/vdsk_int.h Sat Nov 22 02:44:39 2014 (r274838) @@ -31,8 +31,11 @@ struct vdsk { int fd; - int sectorsize; + int fflags; + char *filename; + struct stat fsbuf; off_t capacity; + int sectorsize; } __attribute__((align(16))); #endif /* __VDSK_INT_H__ */