[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 06 of 15 v4] blktap3/libblktapctl: Introduce block device control information retrieval functionality
This patch introduces function tap_ctl_info. It is used by the tapback daemon to retrieve the size of the block device, as well as the sector size, in order to communicate it to blkfront so that it can create the virtual block device. Signed-off-by: Thanos Makatos <thanos.makatos@xxxxxxxxxx> --- Changed since v2: * Simplified error checking after calling tap_ctl_connect_send_and_receive. diff --git a/tools/blktap3/control/tap-ctl-info.c b/tools/blktap3/control/tap-ctl-info.c new file mode 100644 --- /dev/null +++ b/tools/blktap3/control/tap-ctl-info.c @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2012 Citrix Ltd. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + +#include <stdio.h> +#include <string.h> +#include <assert.h> + +#include "tap-ctl.h" +#include "tap-ctl-info.h" + +int tap_ctl_info(pid_t pid, int minor, unsigned long long *sectors, + unsigned int *sector_size, unsigned int *info) +{ + tapdisk_message_t message; + int err; + + assert(sectors); + assert(sector_size); + assert(info); + + memset(&message, 0, sizeof(message)); + message.type = TAPDISK_MESSAGE_DISK_INFO; + message.cookie = minor; + + err = tap_ctl_connect_send_and_receive(pid, &message, NULL); + if (err) { + EPRINTF("failed to get info from tapdisk %d: %s\n", pid, + strerror(err)); + return err; + } + + *sectors = message.u.image.sectors; + *sector_size = message.u.image.sector_size; + *info = message.u.image.info; + return err; +} diff --git a/tools/blktap3/control/tap-ctl-info.h b/tools/blktap3/control/tap-ctl-info.h new file mode 100644 --- /dev/null +++ b/tools/blktap3/control/tap-ctl-info.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2012 Citrix Ltd. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + +#ifndef __TAP_CTL_INFO_H__ +#define __TAP_CTL_INFO_H__ + +/** + * Retrieves virtual disk information from a tapdisk. + * + * @pid the process ID of the tapdisk process + * @minor the minor device number + * @sectors output parameter that receives the number of sectors + * @sector_size output parameter that receives the size of the sector + * @info TODO ? + * + */ +int tap_ctl_info(pid_t pid, int minor, unsigned long long *sectors, + unsigned int *sector_size, unsigned int *info); + +#endif /* __TAP_CTL_INFO_H__ */ _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |