[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH][Xen API] Add model field to VIF class



Currently there is no way to specify the model of VIF for HVM guests via
Xen API.  This patch introduces a 'model' field to the VIF class.

Regards,
Jim
# HG changeset patch
# User Jim Fehlig <jfehlig@xxxxxxxxxx>
# Date 1175015367 21600
# Node ID 930d5ed35a66a4ed8a3fc27236309a680cb3577d
# Parent  10fcea8f51cd28bd7970efb561da9fba879b151f
Add 'model' field to VIF class, enabling specification of emulated vif model 
via Xen API.

Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxxxx>

diff -r 10fcea8f51cd -r 930d5ed35a66 docs/xen-api/xenapi-datamodel.tex
--- a/docs/xen-api/xenapi-datamodel.tex Mon Mar 26 14:10:19 2007 +0100
+++ b/docs/xen-api/xenapi-datamodel.tex Tue Mar 27 11:09:27 2007 -0600
@@ -6979,6 +6979,7 @@ Quals & Field & Type & Description \\
 $\mathit{RO}_\mathit{ins}$ &  {\tt network} & network ref & virtual network to 
which this vif is connected \\
 $\mathit{RO}_\mathit{ins}$ &  {\tt VM} & VM ref & virtual machine to which 
this vif is connected \\
 $\mathit{RW}$ &  {\tt MAC} & string & ethernet MAC address of virtual 
interface, as exposed to guest \\
+$\mathit{RW}$ &  {\tt model} & string & emulated model of vif exposed to guest 
e.g. pcnet \\
 $\mathit{RW}$ &  {\tt MTU} & int & MTU in octets \\
 $\mathit{RO}_\mathit{run}$ &  {\tt currently\_attached} & bool & is the device 
currently attached (erased on reboot) \\
 $\mathit{RO}_\mathit{run}$ &  {\tt status\_code} & int & error/success code 
associated with last attach-operation (erased on reboot) \\
@@ -7277,6 +7278,72 @@ Set the MAC field of the given VIF.
 
  \noindent {\bf Signature:} 
 \begin{verbatim} void set_MAC (session_id s, VIF ref self, string 
value)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VIF ref } & self & reference to the object \\ \hline 
+
+{\tt string } & value & New value to set \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+void
+}
+
+
+
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_model}
+
+{\bf Overview:} 
+Get the model field of the given VIF.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} string get_model (session_id s, VIF ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VIF ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+string
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~set\_model}
+
+{\bf Overview:} 
+Set the model field of the given VIF.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} void set_model (session_id s, VIF ref self, string 
value)\end{verbatim}
 
 
 \noindent{\bf Arguments:}
diff -r 10fcea8f51cd -r 930d5ed35a66 tools/libxen/include/xen_vif.h
--- a/tools/libxen/include/xen_vif.h    Mon Mar 26 14:10:19 2007 +0100
+++ b/tools/libxen/include/xen_vif.h    Tue Mar 27 11:09:27 2007 -0600
@@ -71,6 +71,7 @@ typedef struct xen_vif_record
     struct xen_network_record_opt *network;
     struct xen_vm_record_opt *vm;
     char *mac;
+    char *model;
     int64_t mtu;
     bool currently_attached;
     int64_t status_code;
@@ -224,6 +225,13 @@ xen_vif_get_mac(xen_session *session, ch
 
 
 /**
+ * Get the model field of the given VIF.
+ */
+extern bool
+xen_vif_get_model(xen_session *session, char **result, xen_vif vif);
+
+
+/**
  * Get the MTU field of the given VIF.
  */
 extern bool
@@ -291,6 +299,13 @@ xen_vif_set_device(xen_session *session,
  */
 extern bool
 xen_vif_set_mac(xen_session *session, xen_vif vif, char *mac);
+
+
+/**
+ * Set the model field of the given VIF.
+ */
+extern bool
+xen_vif_set_model(xen_session *session, xen_vif vif, char *model);
 
 
 /**
diff -r 10fcea8f51cd -r 930d5ed35a66 tools/libxen/src/xen_vif.c
--- a/tools/libxen/src/xen_vif.c        Mon Mar 26 14:10:19 2007 +0100
+++ b/tools/libxen/src/xen_vif.c        Tue Mar 27 11:09:27 2007 -0600
@@ -55,6 +55,9 @@ static const struct_member xen_vif_recor
         { .key = "MAC",
           .type = &abstract_type_string,
           .offset = offsetof(xen_vif_record, mac) },
+        { .key = "model",
+          .type = &abstract_type_string,
+          .offset = offsetof(xen_vif_record, model) },
         { .key = "MTU",
           .type = &abstract_type_int,
           .offset = offsetof(xen_vif_record, mtu) },
@@ -253,6 +256,23 @@ xen_vif_get_mac(xen_session *session, ch
 
 
 bool
+xen_vif_get_model(xen_session *session, char **result, xen_vif vif)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vif }
+        };
+
+    abstract_type result_type = abstract_type_string;
+
+    *result = NULL;
+    XEN_CALL_("VIF.get_model");
+    return session->ok;
+}
+
+
+bool
 xen_vif_get_mtu(xen_session *session, int64_t *result, xen_vif vif)
 {
     abstract_value param_values[] =
@@ -413,6 +433,22 @@ xen_vif_set_mac(xen_session *session, xe
         };
 
     xen_call_(session, "VIF.set_MAC", param_values, 2, NULL, NULL);
+    return session->ok;
+}
+
+
+bool
+xen_vif_set_model(xen_session *session, xen_vif vif, char *model)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vif },
+            { .type = &abstract_type_string,
+              .u.string_val = model }
+        };
+
+    xen_call_(session, "VIF.set_model", param_values, 2, NULL, NULL);
     return session->ok;
 }
 
diff -r 10fcea8f51cd -r 930d5ed35a66 tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py  Mon Mar 26 14:10:19 2007 +0100
+++ b/tools/python/xen/xend/XendAPI.py  Tue Mar 27 11:09:27 2007 -0600
@@ -1899,6 +1899,7 @@ class XendAPI(object):
                    'network',
                    'VM',
                    'MAC',
+                   'model',
                    'MTU']
 
     VIF_attr_inst = VIF_attr_rw
@@ -1969,6 +1970,9 @@ class XendAPI(object):
     
     def VIF_get_MAC(self, session, vif_ref):
         return self._VIF_get(vif_ref, 'MAC')
+
+    def VIF_get_model(self, session, vif_ref):
+        return self._VIF_get(vif_ref, 'model')
 
     def VIF_get_device(self, session, vif_ref):
         return self._VIF_get(vif_ref, 'device')
diff -r 10fcea8f51cd -r 930d5ed35a66 tools/python/xen/xend/XendConfig.py
--- a/tools/python/xen/xend/XendConfig.py       Mon Mar 26 14:10:19 2007 +0100
+++ b/tools/python/xen/xend/XendConfig.py       Tue Mar 27 11:09:27 2007 -0600
@@ -1043,6 +1043,8 @@ class XendConfig(dict):
                     dev_info['type'] = cfg_xenapi.get('type')
                 if cfg_xenapi.get('name'):
                     dev_info['name'] = cfg_xenapi.get('name')
+                if cfg_xenapi.get('model'):
+                    dev_info['model'] = cfg_xenapi.get('model')
                 
                 dev_uuid = cfg_xenapi.get('uuid', None)
                 if not dev_uuid:
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.