/* virt-hostinfo * Copyright (C) 2009 Red Hat Inc. * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file makes available all entries in the libvirt NodeInfo * structure. */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include "hostinfod.h" static void model (struct guest_description *hval, const char *cmd, apr_array_header_t *args) { if (get_args (args, "") == -1) { warning ("%s: %s: wrong number or type of arguments", hval->name, __func__); send_error (hval, 400); return; } send_reply (hval, 200, "%s", nodeinfo.model); } REGISTER_COMMAND (model) static void memory (struct guest_description *hval, const char *cmd, apr_array_header_t *args) { if (get_args (args, "") == -1) { warning ("%s: %s: wrong number or type of arguments", hval->name, __func__); send_error (hval, 400); return; } send_reply (hval, 200, "%lu", nodeinfo.memory); } REGISTER_COMMAND (memory) static void availcpus (struct guest_description *hval, const char *cmd, apr_array_header_t *args) { if (get_args (args, "") == -1) { warning ("%s: %s: wrong number or type of arguments", hval->name, __func__); send_error (hval, 400); return; } send_reply (hval, 200, "%u", nodeinfo.cpus); } REGISTER_COMMAND (availcpus) static void physcpus (struct guest_description *hval, const char *cmd, apr_array_header_t *args) { if (get_args (args, "") == -1) { warning ("%s: %s: wrong number or type of arguments", hval->name, __func__); send_error (hval, 400); return; } send_reply (hval, 200, "%u", VIR_NODEINFO_MAXCPUS (nodeinfo)); } REGISTER_COMMAND (physcpus) static void mhz (struct guest_description *hval, const char *cmd, apr_array_header_t *args) { if (get_args (args, "") == -1) { warning ("%s: %s: wrong number or type of arguments", hval->name, __func__); send_error (hval, 400); return; } send_reply (hval, 200, "%u", nodeinfo.mhz); } REGISTER_COMMAND (mhz) static void nodes (struct guest_description *hval, const char *cmd, apr_array_header_t *args) { if (get_args (args, "") == -1) { warning ("%s: %s: wrong number or type of arguments", hval->name, __func__); send_error (hval, 400); return; } send_reply (hval, 200, "%u", nodeinfo.nodes); } REGISTER_COMMAND (nodes) static void socketspernode (struct guest_description *hval, const char *cmd, apr_array_header_t *args) { if (get_args (args, "") == -1) { warning ("%s: %s: wrong number or type of arguments", hval->name, __func__); send_error (hval, 400); return; } send_reply (hval, 200, "%u", nodeinfo.sockets); } REGISTER_COMMAND (socketspernode) static void corespersocket (struct guest_description *hval, const char *cmd, apr_array_header_t *args) { if (get_args (args, "") == -1) { warning ("%s: %s: wrong number or type of arguments", hval->name, __func__); send_error (hval, 400); return; } send_reply (hval, 200, "%u", nodeinfo.cores); } REGISTER_COMMAND (corespersocket) static void threadspercore (struct guest_description *hval, const char *cmd, apr_array_header_t *args) { if (get_args (args, "") == -1) { warning ("%s: %s: wrong number or type of arguments", hval->name, __func__); send_error (hval, 400); return; } send_reply (hval, 200, "%u", nodeinfo.threads); } REGISTER_COMMAND (threadspercore)